gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Searching for blocks with / stopped working for Cyrillic

Open anelkata opened this issue 8 years ago • 4 comments

After I updated to v4 yesterday the / block search stopped showing hits for search terms using Cyrillic characters. Before the update this was working fine.

On typing the slash, the blocks with Cyrillic names appear in the popup, but disappear on typing a Cyrillic character after the slash. Typing a Latin character returns results as usual. The search in the + button menu is working normally and returns results for both Cyrillic and Latin.

I attach screenshots for all cases.

1 2 3 4

anelkata avatar Oct 19 '18 04:10 anelkata

Related to #10489

Soean avatar Oct 19 '18 06:10 Soean

This is a different issue from #10489.

Latin-scripted languages like German can get by with lodash#deburr, which — aside from allowing u to "match" ü — guarantees that the autocompleter input is plain ASCII. ASCII input is a requirement for the way Autocomplete currently works, since it relies on the \w RegExp character class to target the user's input:

https://github.com/WordPress/gutenberg/blob/a563dc773f928f924a81116b1be43cc0a79308bf/packages/components/src/autocomplete/index.js#L402

Per MDN's page on RegExp:

As mentioned above, \w or \W only matches ASCII based characters; for example, "a" to "z", "A" to "Z", "0" to "9" and "_". To match characters from other languages such as Cyrillic or Hebrew, use \uhhhh, where "hhhh" is the character's Unicode value in hexadecimal.

mcsf avatar Oct 23 '18 16:10 mcsf

Related discussion in ECMA262: https://github.com/tc39/ecma262/issues/1020

mcsf avatar Oct 23 '18 16:10 mcsf

Fix in #10961.

mcsf avatar Oct 23 '18 17:10 mcsf