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

fix(filter-field): Fixes a bug where the range overlay was not closed. #854

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
getFilterfieldTags,
tagOverlay,
setupSecondTestScenario,
filterFieldRangePanel,
} from './filter-field.po';
import { Selector } from 'testcafe';
import { waitForAngular, resetWindowSizeToDefault } from '../../utils';
Expand Down Expand Up @@ -287,3 +288,31 @@ test('should remove all removable filters when clicking the clear-all button', a
.expect(filterTags.count)
.eql(1);
});

test('should close the range when blurring the filter field mid filter, returning back and deleting the current filter', async (testController: TestController) => {
// Setup the second datasource.
await testController
.click(setupSecondTestScenario)
// Wait for the filterfield to catch up.
.wait(500);

await clickOption(2);

await testController
.click(Selector('.outside'))
.expect(filterFieldRangePanel.exists)
.notOk();

// Focus the filter field again,
// press backspace - deleting the current filter
// the range should now be closed.
await focusFilterFieldInput();
await testController
.expect(filterFieldRangePanel.exists)
.ok()
.wait(250)
.pressKey('backspace')
.wait(250)
.expect(filterFieldRangePanel.exists)
.notOk();
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export const option = (nth: number) => Selector(`.dt-option:nth-child(${nth})`);
export const clearAll = Selector('.dt-filter-field-clear-all-button');
export const filterTags = Selector('dt-filter-field-tag');
export const tagOverlay = Selector('.dt-overlay-container');
export const filterFieldRangePanel = Selector('.dt-filter-field-range-panel');

export const input = Selector('input');

export const switchToFirstDatasource = Selector('#switchToFirstDatasource');
export const switchToSecondDatasource = Selector('#switchToSecondDatasource');
export const setupSecondTestScenario = Selector('#setupSecondTestScenario');

export function clickOption(
nth: number,
testController?: TestController,
Expand Down
5 changes: 5 additions & 0 deletions libs/barista-components/filter-field/src/filter-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ export class DtFilterField<T>
// show the panel again.
// Note: Also trigger openPanel if it already open, so it does a reposition and resize
this._autocompleteTrigger.openPanel();
// If a range is currently open but an autocomplete should be shown
// we need to close the range panel again.
if (this._filterfieldRange.isOpen) {
this._filterfieldRangeTrigger.closePanel();
}
} else if (isDtRangeDef(this._currentDef)) {
this._filterfieldRangeTrigger.openPanel();
this._filterfieldRangeTrigger.range.focus();
Expand Down