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

fix: filters: clear search values when clear or clear all occurs #5006

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

margaree
Copy link
Contributor

@margaree margaree commented Sep 24, 2024

Jira ticket

Problems:

  • If text is entered in the search field but the search event doesn't actually happen (i.e., enter being pressed or the search button being clicked) then the search input text does not get cleared.
  • Additionally, when "clear all" was clicked, it would clear searched text, but when "clear" was clicked in the dimension where the search was performed it would NOT clear the search text.

To do:

  • tests

Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-5006/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Comment on lines +740 to +741
const searchInput = this.shadowRoot.querySelector('d2l-input-search');
if (searchInput) searchInput.value = '';
Copy link
Contributor Author

@margaree margaree Sep 24, 2024

Choose a reason for hiding this comment

The 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 value technically isn't changing for the case where the user hasn't actually executed the search (the value within d2l-input-search is changing but not the one that filter is rendering). Let me know any suggestions here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that because dimension.searchValue doesn't change until they execute the search? Could its value be set to empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 _handleClearSearch but it already was empty so to filter nothing has changed.

@@ -735,6 +735,12 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
_handleClear() {
const dimension = this._getActiveDimension();

if (dimension.searchType !== 'none') {
this._handleClearSearch(dimension);
Copy link
Contributor Author

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.

@margaree margaree marked this pull request as ready for review September 24, 2024 19:37
@margaree margaree requested a review from a team as a code owner September 24, 2024 19:37
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@margaree margaree merged commit a1dfe2f into main Sep 25, 2024
6 checks passed
@margaree margaree deleted the filter-search-not-clearing branch September 25, 2024 16:30
Copy link

🎉 This PR is included in version 3.44.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants