Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(filter-field): Fixed UX problem where text that wasn't applied to…
Browse files Browse the repository at this point in the history
… the filter would remain after losing focus.
  • Loading branch information
rebu-dt authored and lukasholzer committed Sep 10, 2020
1 parent a824efc commit dbddb97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libs/barista-components/filter-field/src/filter-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ describe('DtFilterField', () => {
});
});

describe('focus loss', () => {
it('should clear the current input value', fakeAsync(() => {
const input = fixture.debugElement.query(By.css('.dt-filter-field-input'))
.nativeElement;

filterField.focus();
typeIntoFilterElement('foo');
input.blur();
tick();

expect(input.value).toBe('');
}));
});

describe('disabled', () => {
it('should disable the input if filter field is disabled', () => {
// when
Expand Down
4 changes: 4 additions & 0 deletions libs/barista-components/filter-field/src/filter-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ export class DtFilterField<T = any>
// Assign the currently open filter field when it is focused.
if (this._isFocused) {
currentlyOpenFilterField = this;
} else {
// Clear pending input values on focus loss to communicate that the input
// wasn't applied as a filter
this._writeInputValue('');
}
});

Expand Down

0 comments on commit dbddb97

Please sign in to comment.