Skip to content

Taxonomy term filtering does not normalize full-width/half-width characters (e.g. ABC vs ABC) #70169

@fumikito

Description

@fumikito

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:

https://github.com/WordPress/gutenberg/blob/HEAD/packages/editor/src/components/post-taxonomies/hierarchical-term-selector.js#L139

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

  1. Go to 'Category' in WordPress Admin.
  2. Register 2 terms "PlayStation 2" and "PlayStation 2".
  3. Search with "play" or "Play"
  4. At least 2 terms match.
  5. Go to editor screen, search categories with query "play" in inspect controls(search field won't appear if categories length is less than 8
  6. Only 1 term matches.

Screenshots, screen recording, code snippet

In WordPress wp-admin/edit-tags.php

Image

A half-width query "Play" matches with "PlayStation 2" and "PlayStation 2".

Image

A full-width query "110" matches with "警察は110番" and "警察は110番".

In the block editor

Image

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

Metadata

Metadata

Assignees

Labels

Internationalization (i18n)Issues or PRs related to internationalization efforts[Status] In ProgressTracking issues with work in progress[Status] In discussionUsed to indicate that an issue is in the process of being discussed[Type] EnhancementA suggestion for improvement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions