fix(autocomplete-preset-algolia): support Unicode in ReverseHighlight#1330
Merged
Haroenv merged 2 commits intoalgolia:fix/unicode-highlightingfrom Jan 28, 2026
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 29fe8c4:
|
Haroenv
approved these changes
Jan 28, 2026
Contributor
Haroenv
left a comment
There was a problem hiding this comment.
thanks, this looks great, and still safe for older browsers
Contributor
|
moved to #1331 so that CI can run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes ReverseHighlight behavior for non-ASCII queries (e.g., Japanese and Cyrillic) in
@algolia/autocomplete-preset-algolia.isPartHighlightedpreviously used an ASCII-only\wcheck to detect "word characters". In JavaScript,\wmatches[A-Za-z0-9_]and does not match Unicode letters. As a result, Unicode text could be treated as a "separator" by the normalization logic, which could lead to incorrect ReverseHighlight output (see #1317).This change replaces the ASCII-only check with a Unicode-aware check (Unicode property escapes) and renames the variable accordingly. A fallback to the previous
\wbehavior is kept for environments where Unicode property escapes are unavailable.Result
Output:
fixes #1317
UI Evidence (Before / After)
Before (current behavior)
音声After (this PR)
音声