From 45a78c7445e79a69a7a27333a700eab6543f2b75 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 6 Apr 2021 18:01:41 +0200 Subject: [PATCH] Query by the term from last trigger prefix character --- packages/components/src/autocomplete/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/src/autocomplete/index.js b/packages/components/src/autocomplete/index.js index 8138d355285fa6..af1b9a7c611b7f 100644 --- a/packages/components/src/autocomplete/index.js +++ b/packages/components/src/autocomplete/index.js @@ -472,9 +472,9 @@ function Autocomplete( { } const safeTrigger = escapeRegExp( completer.triggerPrefix ); - const match = text.match( - new RegExp( `${ safeTrigger }([\u0000-\uFFFF]*)$` ) - ); + const match = text + .slice( text.lastIndexOf( completer.triggerPrefix ) ) + .match( new RegExp( `${ safeTrigger }([\u0000-\uFFFF]*)$` ) ); const query = match && match[ 1 ]; setAutocompleter( completer );