Fix: Enhance autocomplete search for special characters (accents)#406
Fix: Enhance autocomplete search for special characters (accents)#406bob10042 wants to merge 1 commit intothoughtworks:masterfrom
Conversation
- Added textNormalizer.js utility with normalizeText() function - Uses Unicode NFD normalization to remove diacritical marks - Allows accent-insensitive search (e.g., 'Autorizacao' matches 'Autorização') - Supports Portuguese, Spanish, French, German and other accented languages - Added 9 comprehensive unit tests for normalization function This enables users who type without accents to find blips that contain accented characters in their names or descriptions, improving accessibility for non-English users. Fixes thoughtworks#356
There was a problem hiding this comment.
Pull request overview
This PR introduces accent-insensitive text normalization and wires it into the autocomplete search so users can find items regardless of diacritical marks (e.g., Portuguese, Spanish, French, German accents).
Changes:
- Added
src/util/textNormalizer.jswithnormalizeText()using lowercase + Unicode NFD + combining-mark stripping. - Updated
src/util/autoComplete.jsto run both the searchable text and query terms throughnormalizeTextbefore matching. - Added unit tests in
spec/util/autoComplete-spec.jsto verifynormalizeTextbehavior across multiple languages and edge cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/util/textNormalizer.js | Defines and exports the normalizeText helper used for accent-insensitive matching. |
| src/util/autoComplete.js | Integrates normalizeText into the autocomplete source filter for both UI variants. |
| spec/util/autoComplete-spec.js | Adds tests that validate normalizeText output for accented, mixed, and non-accented input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| describe('autoComplete', () => { | ||
| describe('normalizeText', () => { | ||
| it('should convert text to lowercase', () => { |
There was a problem hiding this comment.
This spec file is named autoComplete-spec.js and the top-level describe is 'autoComplete', but the tests only exercise normalizeText from textNormalizer.js. Other util specs (for example spec/util/urlUtils-spec.js:1-6 and spec/util/inputSanitizer-spec.js:1-4) follow a convention where the spec file name and top-level describe match the module under test. To keep tests discoverable and aligned with that convention, consider renaming this spec to something like textNormalizer-spec.js and updating the top-level describe to 'textNormalizer' (or similar).
Summary
Enhances the autocomplete search to support special characters and accents, making the search accessible for non-English users (Portuguese, Spanish, French, German, etc.).
Problem
The autocomplete search did not match words containing accented characters. For example, searching for 'Autorizacao' would not find 'Autorização', and 'Experiencia' would not match 'Experiência'.
Solution
Implemented Unicode NFD normalization to strip diacritical marks from both the search query and searchable text, enabling accent-insensitive matching.
Changes
Technical Details
The normalizeText() function:
Testing
Fixes #356
Third contribution to this project!