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

[FiltersBar] Fix vanishing filters #11417

Merged
merged 4 commits into from
Jan 15, 2024
Merged

Conversation

mrcthms
Copy link
Contributor

@mrcthms mrcthms commented Jan 9, 2024

WHY are these changes introduced?

Fixes https://github.com/Shopify/web/issues/114283

We currently have a bug in the FiltersBar component, where if all filters are pinned on mount, and a merchant either clicks the "Clear all" button, or clears a filter individually, then that filter vanishes until the merchant refreshes the page.

The cause of this was some missing logic to determine whether to show the Add filter button. Previously, it only checked for pinned filters on mount, and not for changes to the pinned filter state.

How to 🎩

Spin URL: https://admin.web.vanishing-filters.marc-thomas.eu.spin.dev/store/shop1/collections?selectedView=all
Story instance: https://5d559397bae39100201eedc1-epgxutgfws.chromatic.com/?path=/story/all-components-filters--with-all-filters-pinned

🎩 checklist

@mrcthms
Copy link
Contributor Author

mrcthms commented Jan 9, 2024

/snapit

Copy link
Contributor

github-actions bot commented Jan 9, 2024

🫰✨ Thanks @mrcthms! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240109112719
yarn add @shopify/polaris@0.0.0-snapshot-release-20240109112719
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240109112719
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240109112719

Copy link
Contributor

@sophschneider sophschneider left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this! Hmm its still happening for me on this PR's storybook 🤔, is it just an issue with the story callback functions themselves or the Filters logic?

Screen.Recording.2024-01-09.at.10.29.06.AM.mov

@sophschneider sophschneider added Uplift polish Fast follow fixes and polish post Summer Editions and removed Uplift polish Fast follow fixes and polish post Summer Editions labels Jan 9, 2024
@mrcthms
Copy link
Contributor Author

mrcthms commented Jan 9, 2024

@sophschneider That's expected now, the issue we're fixing in this PR is what is seen in the video below, where the filters vanish when clearing. The filters now appear in the Popover behind the "Add filters" button when cleared.

We intentionally changed functionality so that if a filter is interacted with and cleared, we unpin it, even if it was pinned when the component mounts. This was due to the filters bar feeling cluttered with empty filters when an IndexFilters with multiple pinned filters was used.

Screen.Recording.2024-01-09.at.17.15.57.mov

Copy link
Contributor

@tatianau tatianau left a comment

Choose a reason for hiding this comment

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

Hey @mrcthms , thanks for looking into this! 🙏 Our team @Shopify/variants-foundations-frontend initially discovered three issues that might have the same underlying problem, here's a breakdown:

Issue 1

When the popover is opened and then clicked outside, the filter disappears and cannot be reopened without reloading the page.

Video
09-02-bd4g7-6ouc0.mp4

Issue 2

When a filter is set and then cleared individually, it also disappears without the ability to reopen it without reloading the page.

Video
09-03-gsoav-vhc0l.mp4

Issue 3

The "Clear all" button is displayed even when there are no filters to clear, for example, when a filter is set and then unset.

Video
09-03-gsoav-vhc0l.mp4

Thanks for providing the context. It seems that the issues with removing pinned filters in 1 and 2 were actually intentional design choices. However, the problem lies in the inability to reopen those filters after they have been removed which is being fixed by this PR. This PR also seems to have resolved issue 3 as well.

Does that sound accurate to you?

Could you please restart the spin instance as it seems to be dead 😨

@mrcthms
Copy link
Contributor Author

mrcthms commented Jan 10, 2024

/snapit

Copy link
Contributor

🫰✨ Thanks @mrcthms! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240110081218
yarn add @shopify/polaris@0.0.0-snapshot-release-20240110081218
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240110081218
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240110081218

@mrcthms
Copy link
Contributor Author

mrcthms commented Jan 10, 2024

@tatianau Yes, that's correct on all three counts. I've updated the Spin instance with the latest snapshot which hides the Clear all button if there's nothing to clear, so you should see that on the Spin.

Also, with the new Spin rules around more aggressive suspending of Spin instances, you may find this link handy, where you can resume the spinstance yourself if it goes down by the time you see this

@supervee
Copy link

I find this behaviour really bizarre from a UX standpoint ... "clear" implies clearing the selection, but to have the entire filter disappear feels really jarring. Even more so when it's just a mouseclick out of the popover. This is particularly weird for filters we've pre-pinned. Is there any chance we could revisit this UX decision?

@slack-github-archiver
Copy link

Summary

  • Tatiana Uspenskaia requested assistance on an issue related to pinned Filters in Polaris. Sophie Schneider identified the potential cause as a specific PR that updated the logic and potentially introduced the bug in version 12.2.0.
  • Marc Thomas confirmed that the issue might be related to his work and committed to provide a fix. He later shared a PR with a fix.
  • Veronica Wong raised a UX concern about the behavior of filters disappearing when cleared, especially pre-pinned ones. Jordan Ouellette clarified that some of the behaviors were bugs and not by design, and he would work on fixing them.
  • Jordan Ouellette confirmed that pre-pinned filters should never unpin implicitly no matter the interaction with them. If they do, it's a bug. This understanding was confirmed by Tatiana Uspenskaia.
  • The team will work on fixing the identified bugs and improving the UX of the filter feature.

This summary was generated using OpenAI's gpt-4 with a temperature of 0.5.

🧵 Slack Thread
User Message
👤 <@USLACKBOT>
2023‑12‑19 22:40
This message was deleted.
Tatiana Uspenskaia
2024‑01‑08 18:47
Could I please get assistance on the *pinned Filters* issue from <@@polaris-developers>? 🙏
Sophie Schneider
2024‑01‑08 19:08
hey @tatianau! I used the codesandbox you linked to find out what version of polaris this bug was introduced, I think its 12.2.0 . Just looking through the version packages pr for that version, there are quite a few changes to Filters so I'll just look through their storybooks now
Sophie Schneider
2024‑01‑08 19:14
My gut thinks this PR is the culprit since it mentions pinned filters and it updates the logic
Sophie Schneider
2024‑01‑08 19:25
I think it is that PR, using an old storybook the pinned filters persist when clearing all vs. the storybook on that PR which clears the pinned filters. @mrcthms, would you have time to take a look at this bug :pray1:?
Sophie Schneider
2024‑01‑08 19:31
I think this issue might have also been introduced in that PR
Marc Thomas
2024‑01‑09 10:38
Yep, looks related to work I did last year - I'll look at getting a fix out for you all!
Natalie Dodd
2024‑01‑09 11:41
Hi @mrcthms! Do you have a ticket I can reference to track this issue? We are also seeing it in Collective on version 12.6.0. Any time a filter is closed or cleared, it is no longer pinned:
Marc Thomas
2024‑01‑09 11:51
Hi @nattydodd I have a PR ready to go for the fix here, with a Spin link if you want to tophat for your area too
Natalie Dodd
2024‑01‑09 11:52
Awesome thank you!
Veronica Wong
2024‑01‑10 20:04
Hi friends! I left a comment in the PR too but thought maybe this might be a good place for conversation:
I find this behaviour really bizarre from a UX standpoint ... “clear” implies clearing the selection, but to have the entire filter disappear feels really jarring. Even more so when it’s just a mouseclick out of the popover. This is particularly weird for filters we’ve pre-pinned. Is there any chance we could revisit this UX decision?
Sophie Schneider
2024‑01‑10 20:05
cc: @ouellettejordan @davidlng do you happen to have any context on this ux decision?
Jordan Ouellette
2024‑01‑10 20:10
@supervee are you referring to Clear all? I’m not aware of a Clear action on the filter and search experience
Jordan Ouellette
2024‑01‑10 20:11
As an aside…
Screenshot 2024-01-10 at 3.11.15 PM.png
Jordan Ouellette
2024‑01‑10 20:11
Who built/designed this? Not sure why the divergence or even what this Search button does?
Veronica Wong
2024‑01‑10 20:18
clear in this example
Screen Shot 2024-01-10 at 15.18.47 PM.png
Jordan Ouellette
2024‑01‑10 20:33
Ah, this was not us. This has been this way for a very long time from what I know. We just worked on top level presentation, not this level of filter behaviour/ux
Veronica Wong
2024‑01‑10 20:36
The thing I’m wondering about is the new action of clearing a pre-pinned filter when you click out of it (and it doesn’t have a selection)
Natalie Dodd
2024‑01‑10 21:58
@ouellettejordan that Search button will be replaced shortly, it's left over from a legacy component. We have a PR in progress to use the default Filter search functionality. It's not by design.
Jordan Ouellette
2024‑01‑11 15:22
@supervee oooo, yes we did that. However, what you are describing a bug — not by design. Good catch.
Jordan Ouellette
2024‑01‑11 15:23
We’ll get that fixed asap. Thank you!
Jordan Ouellette
2024‑01‑11 15:29
Issue in our board to fix
Sophie Schneider
2024‑01‑11 15:33
just confirming this comment, is clearing pre pinned filters on "Clear all" intentional as well?
Jordan Ouellette
2024‑01‑11 15:34
Oh, yeah — Clear all should not be there unless you have custom added filters
Jordan Ouellette
2024‑01‑11 15:34
Will add this to the issue as well
Jordan Ouellette
2024‑01‑11 15:34
Thanks @sophschneider
Tatiana Uspenskaia
2024‑01‑11 17:44
@ouellettejordan Could you please clarify, from what I've gathered:

• Removing pre-pinned filter on popover dismiss is a bug
• Removing pre-pinned filters on "clear all" is not a bug and is a deliberate design choice
• Removing pre-pinned filter when clicking "clear" within that filter popover - is that a bug or by design?

Jordan Ouellette
2024‑01‑11 17:46
@tatianau your second item there is mentioned as a bug as well (mentioned this in the video on issue). As for that last one, I missed this… that would also be a bug — clear should clear the selection in the popover, not the pre-pinned filter itself. I’ll add this to the issue as well.
Tatiana Uspenskaia
2024‑01‑11 17:49
Alright, so it sounds like it filter is set to be pre-pinned by consumer - it should never unpin implicitly no matter the interaction with it, is that correct? That's how it was working before and that's how our team assumed it should be working, otherwise, it sort of defeats the purpose of controlling the "pinned" state at consumer level :kermit-think:
Jordan Ouellette
2024‑01‑11 17:51
so it sounds like it filter is set to be pre-pinned by consumer
Jordan Ouellette
2024‑01‑11 17:51
Merchants (consumer?) can’t pre-pin filters — these are determined by Shopify
Jordan Ouellette
2024‑01‑11 17:52
But yes, these pre-pinned (by Shopify) filters should never be able to be dismissed by merchants
Tatiana Uspenskaia
2024‑01‑11 17:53
By consumer I mean the admin FED, the person who configures the way we want to get the filters displayed to merchants. So if we set our filters in a variants card to be pinned for merchants - they should remain pinned no matter the merchant interaction with them, and if they don't - it's a bug. Right?
Jordan Ouellette
2024‑01‑11 17:53
Got it
Jordan Ouellette
2024‑01‑11 17:53
Correct
Jordan Ouellette
2024‑01‑11 17:53
Not sure if this current behaviour we’re discussinng is a regression or a miss from our team when we implemented the dismiss on click outside ux
Jordan Ouellette
2024‑01‑11 17:54
Either way, we’ll get it fixed
Tatiana Uspenskaia
2024‑01‑11 17:54
Thank you all so much :bow-girl: :dreamteam: :thank:
Jordan Ouellette
2024‑01‑11 17:57
Sorry, that took a bit to come around to understanding what we were talking about at first

Tatiana Uspenskaia archived this conversation from polaris at 2024‑01‑11 18:04.
All times are in UTC.

@mrcthms
Copy link
Contributor Author

mrcthms commented Jan 12, 2024

/snapit

Copy link
Contributor

🫰✨ Thanks @mrcthms! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240112094043
yarn add @shopify/polaris@0.0.0-snapshot-release-20240112094043
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240112094043
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240112094043

Copy link
Contributor

@tatianau tatianau left a comment

Choose a reason for hiding this comment

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

Thank you so much for fixing pinned filters @mrcthms! Tophatted in storybook and can confirm:


  • ✅ Not removing pre-pinned filter on popover dismiss is fixed
  • ✅ Not removing pre-pinned filters on "clear all" is fixed
  • ✅ Not removing pre-pinned filter when clicking "clear" within that filter popover is fixed
  • ✅ "Clear all" is only rendered when filter(s) applied and removed when there is nothing to clear

giphy copy 3

@mrcthms mrcthms merged commit cea2dd2 into main Jan 15, 2024
12 checks passed
@mrcthms mrcthms deleted the mrcthms-filters-vanishing-fix branch January 15, 2024 09:18
alex-page pushed a commit that referenced this pull request Jan 15, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @shopify/polaris@12.10.0

### Minor Changes

- [#11417](#11417)
[`cea2dd22b`](cea2dd2)
Thanks [@mrcthms](https://github.com/mrcthms)! - [FiltersBar] Fixed bug
where filters would disappear from the FiltersBar when clicking the
Clear all button

### Patch Changes

- [#11446](#11446)
[`6e40eca5e`](6e40eca)
Thanks [@mrcthms](https://github.com/mrcthms)! - [Icons] Fixed
references to incorrect icon imports that were causing Storybook to
break

## polaris.shopify.com@0.61.9

### Patch Changes

- [#11446](#11446)
[`6e40eca5e`](6e40eca)
Thanks [@mrcthms](https://github.com/mrcthms)! - [Icons] Fixed
references to incorrect icon imports that were causing Storybook to
break

- Updated dependencies
\[[`6e40eca5e`](6e40eca),
[`cea2dd22b`](cea2dd2)]:
    -   @shopify/polaris@12.10.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AnnaCheba pushed a commit to AnnaCheba/polaris that referenced this pull request Apr 22, 2024
### WHY are these changes introduced?

Fixes Shopify/web#114283

We currently have a bug in the FiltersBar component, where if all
filters are pinned on mount, and a merchant either clicks the "Clear
all" button, or clears a filter individually, then that filter vanishes
until the merchant refreshes the page.

The cause of this was some missing logic to determine whether to show
the Add filter button. Previously, it only checked for pinned filters on
mount, and not for changes to the pinned filter state.


### How to 🎩

Spin URL:
https://admin.web.vanishing-filters.marc-thomas.eu.spin.dev/store/shop1/collections?selectedView=all
Story instance:
https://5d559397bae39100201eedc1-epgxutgfws.chromatic.com/?path=/story/all-components-filters--with-all-filters-pinned

### 🎩 checklist

- [x] Tested a
[snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases)
- [x] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [x] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [x] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [x] Updated the component's `README.md` with documentation changes
- [x] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants