Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -2,6 +2,10 @@

**Breaking changes**

- Changed `EuiSearchBar` to preserve phrases with leading and trailing spaces, instead of dropping surrounding whitespace ([#5514](https://github.com/elastic/eui/pull/5514))

**Breaking changes**

Comment thread
cee-chen marked this conversation as resolved.
Outdated
- Removed `data-test-subj="dataGridWrapper"` from `EuiDataGrid` in favor of `data-test-subj="euiDataGridBody"` ([#5506](https://github.com/elastic/eui/pull/5506))

## [`44.0.0`](https://github.com/elastic/eui/tree/v44.0.0)
Expand Down
14 changes: 7 additions & 7 deletions src-docs/src/views/search_bar/search_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
const random = new Random();

const tags = [
{ name: 'marketing', color: 'danger' },
{ name: 'finance', color: 'success' },
{ name: 'eng', color: 'success' },
{ name: 'sales', color: 'warning' },
{ name: ' marketing', color: 'danger' },
{ name: ' finance', color: 'success' }, // NB: this is a tab character
{ name: ' eng ', color: 'success' },
{ name: 'sa les', color: 'warning' },
{ name: 'ga', color: 'success' },
];

Expand Down Expand Up @@ -85,11 +85,11 @@ export const SearchBar = () => {
field: 'status',
items: [
{
value: 'open',
value: ' open',
name: 'Open',
},
{
value: 'closed',
value: 'closed ',
name: 'Closed',
},
],
Expand All @@ -104,7 +104,7 @@ export const SearchBar = () => {
type: 'field_value_toggle',
name: 'Mine',
field: 'owner',
value: 'dewey',
value: ' dewey',
},
{
type: 'field_value_toggle',
Expand Down
8 changes: 4 additions & 4 deletions src/components/search_bar/query/default_syntax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ describe('defaultSyntax', () => {
expect(printedQuery).toBe(query);
});

test('relaxed phrases with spaces', () => {
const query = 'f:" this is a relaxed phrase \t"';
test('phrases with spaces', () => {
const query = 'f:" this is a phrase that preserves spaces\t"';
const ast = defaultSyntax.parse(query);

expect(ast).toBeDefined();
Expand All @@ -574,10 +574,10 @@ describe('defaultSyntax', () => {
expect(AST.Field.isInstance(clause)).toBe(true);
expect(AST.Match.isMustClause(clause)).toBe(true);
expect(clause.field).toBe('f');
expect(clause.value).toBe('this is a relaxed phrase');
expect(clause.value).toBe(' this is a phrase that preserves spaces ');

const printedQuery = defaultSyntax.print(ast);
expect(printedQuery).toBe('f:"this is a relaxed phrase"');
expect(printedQuery).toBe('f:" this is a phrase that preserves spaces "');
});

test('phrases with extra characters', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/search_bar/query/default_syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ containsValue
/ word

phrase
= '"' space? phrase:(
(phraseWord+)? (space phraseWord+)* { return unescapePhraseValue(text()); }
) space? '"' { return Exp.string(phrase, location()); }
= '"' phrase:(
space? (phraseWord+)? (space phraseWord+)* space? { return unescapePhraseValue(text()); }
) '"' { return Exp.string(phrase, location()); }

phraseWord
// not a backslash, quote, or space
Expand Down