Skip to content

Conversation

@bob10042
Copy link

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

  • Created new textNormalizer.js utility with normalizeText() function
  • Updated autoComplete.js to use the normalizer for search matching
  • Added 9 comprehensive unit tests covering Portuguese, Spanish, French, and German accents

Technical Details

The normalizeText() function:

  1. Converts text to lowercase
  2. Applies NFD (Canonical Decomposition) normalization
  3. Removes Unicode combining diacritical marks (U+0300 to U+036F)

Testing

  • All 127 unit tests pass
  • Tested with various accented characters from multiple languages

Fixes #356


Third contribution to this project!

- 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
@bob10042 bob10042 requested a review from a team as a code owner January 29, 2026 21:05
Copilot AI review requested due to automatic review settings January 29, 2026 21:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js with normalizeText() using lowercase + Unicode NFD + combining-mark stripping.
  • Updated src/util/autoComplete.js to run both the searchable text and query terms through normalizeText before matching.
  • Added unit tests in spec/util/autoComplete-spec.js to verify normalizeText behavior 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.

Comment on lines +3 to +5
describe('autoComplete', () => {
describe('normalizeText', () => {
it('should convert text to lowercase', () => {
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance auto complete search for special characters (eg.: pt-br accents)

1 participant