-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: filters: clear search values when clear or clear all occurs #5006
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -735,6 +735,12 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) { | |
_handleClear() { | ||
const dimension = this._getActiveDimension(); | ||
|
||
if (dimension.searchType !== 'none') { | ||
this._handleClearSearch(dimension); | ||
const searchInput = this.shadowRoot.querySelector('d2l-input-search'); | ||
if (searchInput) searchInput.value = ''; | ||
Comment on lines
+740
to
+741
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't great. I haven't been able so far to force this search to re-render since its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup I believe that's correct. It's getting set to empty string in |
||
} | ||
|
||
this._performDimensionClear(dimension); | ||
this._dispatchChangeEventNow(false); | ||
this.requestUpdate(); | ||
|
@@ -743,20 +749,33 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) { | |
} | ||
|
||
_handleClearAll() { | ||
let hasSearch = false; | ||
this._dimensions.forEach(dimension => { | ||
if (dimension.searchType !== 'none' && dimension.searchValue !== '') { | ||
dimension.searchValue = ''; | ||
this._search(dimension); | ||
if (dimension.searchType !== 'none') { | ||
this._handleClearSearch(dimension); | ||
hasSearch = true; | ||
} | ||
this._performDimensionClear(dimension); | ||
}); | ||
|
||
if (hasSearch) { | ||
const searchInputs = this.shadowRoot.querySelectorAll('d2l-input-search'); | ||
searchInputs?.forEach((searchInput) => searchInput.value = ''); | ||
} | ||
|
||
this._dispatchChangeEventNow(true); | ||
this.requestUpdate(); | ||
|
||
this.text ? announce(this.localize('components.filter.clearAllAnnounceOverride', { filterText: this.text })) : announce(this.localize('components.filter.clearAllAnnounce')); | ||
} | ||
|
||
_handleClearSearch(dimension) { | ||
if (dimension.searchValue === '') return; | ||
|
||
dimension.searchValue = ''; | ||
this._search(dimension); | ||
} | ||
|
||
_handleDimensionDataChange(e) { | ||
const changes = e.detail.changes; | ||
const dimension = this._getDimensionByKey(e.detail.dimensionKey); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clicking the "Clear" button within a single button was not clearing the search. I confirmed with Jeff that we would want it to. "Clear All" already clears all the searches within the filter so this makes that consistent.