Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-ASCII characters in EuiSearchBar & Query #1415

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
- Added `onBlur` prop to `EuiComboBox` ([#1400](https://github.com/elastic/eui/pull/1400))
- Added `initialFocus` prop typedefs to `EuiModal` and `EuiPopover` ([#1410](https://github.com/elastic/eui/pull/1410))

**Bug fixes**

- Support extended characters (e.g. non-latin, unicode) in `EuiSearchBar` and `EuiQuery` ([#1415](https://github.com/elastic/eui/pull/1415))

## [`6.2.0`](https://github.com/elastic/eui/tree/v6.2.0)

- Added `logoCodesandbox` and updated `apmApp` icons ([#1407](https://github.com/elastic/eui/pull/1407))
Expand Down
10 changes: 10 additions & 0 deletions src/components/search_bar/query/default_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ wordChar
= alnum
/ [-_*:]
/ escapedChar
/ extendedGlyph

// This isn't _strictly_ correct:
// for our purposes, a non-ascii word character is considered to
// be anything above \`Latin-1 Punctuation & Symbols\`, which ends at U+00BF
// This allows any non-ascii character, including the full set of unicode characters
// even those in the supplementary planes (U+010000 → U+10FFFF) as those will be seen individually
// in their surrogate pairs which are of the format /[\uD800-\uDBFF][\uDC00-\uDFFF]/
extendedGlyph
= [\u00C0-\uFFFF]

escapedChar
= "\\\\" reservedChar
Expand Down
22 changes: 22 additions & 0 deletions src/components/search_bar/query/default_syntax.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ describe('defaultSyntax', () => {
expect(clause.value).toBe('dash-3');
});

test('unicode field and term values', () => {
const query = 'name:👸Queen_Elizabeth 🤴King_Henry';
const ast = defaultSyntax.parse(query);

expect(ast).toBeDefined();
expect(ast.clauses).toBeDefined();
expect(ast.clauses).toHaveLength(2);

let clause = ast.getSimpleFieldClause('name', '👸Queen_Elizabeth');
expect(clause).toBeDefined();
expect(AST.Field.isInstance(clause)).toBe(true);
expect(AST.Match.isMustClause(clause)).toBe(true);
expect(clause.field).toBe('name');
expect(clause.value).toBe('👸Queen_Elizabeth');

clause = ast.getTermClause('🤴King_Henry');
expect(clause).toBeDefined();
expect(AST.Term.isInstance(clause)).toBe(true);
expect(AST.Match.isMustClause(clause)).toBe(true);
expect(clause.value).toBe('🤴King_Henry');
});

test('escaped chars as default clauses', () => {
const query = '-\\: \\\\';
const ast = defaultSyntax.parse(query);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13720,6 +13720,11 @@ underscore@~1.4.4:
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.4.4.tgz#61a6a32010622afa07963bf325203cf12239d604"
integrity sha1-YaajIBBiKvoHljvzJSA88SI51gQ=

unicode-11.0.0@^0.7.8:
version "0.7.8"
resolved "https://registry.yarnpkg.com/unicode-11.0.0/-/unicode-11.0.0-0.7.8.tgz#5eecdd6c2802fdd6b260661c57921d0294aeea98"
integrity sha512-O/7kwPxe1ZOiwbLr4/OleBnUDwDRldjubW5SqcQvz1b2EMPp5mQotOdf4L1z/5CNzSDVmWM9cFmseOI6L8vb6g==

unicode-canonical-property-names-ecmascript@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818"
Expand Down