-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Description
When selecting hierarchical taxonomies (e.g., Categories), terms whose names are in full-width characters (e.g., “ABC”) cannot be searched using half-width equivalents (e.g., “ABC”).
In MySQL-backed queries like edit-tags.php, collation settings like utf8mb4_general_ci allow matching across full-width and half-width characters. However, in Gutenberg’s JS-based filter:
Matching is done using includes()
and .toLowerCase()
only, which does not account for Unicode normalization.
Suggested fix:
Add Unicode normalization .normalize('NFKC') to both term names and search strings:
return term.name
.normalize( 'NFKC' )
.toLowerCase()
.includes( search.normalize( 'NFKC' ).toLowerCase() );
Unicode normalization with NFKC allows for consistent comparison between full-width and half-width forms, such as ABC and ABC.
This allows Japanese users (or others using full-width characters) to search more intuitively.
Step-by-step reproduction instructions
- Go to 'Category' in WordPress Admin.
- Register 2 terms "PlayStation 2" and "PlayStation 2".
- Search with "play" or "Play"
- At least 2 terms match.
- Go to editor screen, search categories with query "play" in inspect controls(search field won't appear if categories length is less than 8
- Only 1 term matches.
Screenshots, screen recording, code snippet
In WordPress wp-admin/edit-tags.php
A half-width query "Play" matches with "PlayStation 2" and "PlayStation 2".
A full-width query "110" matches with "警察は110番" and "警察は110番".
In the block editor
In block editor, only width-sensitive matches. Flat taxonomy controls seem to be in the same situation.
Environment info
- WordPress 6.8.1
- Chrome
- Mac OS X
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure