-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Filters] Fix hitting max call depth when appliedFilters is undefined #10711
Conversation
6316805
to
4feb30f
Compare
Currently `appliedFilters` can be `undefined`, except when it is when we try to `setLocalPinnedFilters`, we'll do so forever because we fail the check to decide whether to try set state or not every time, as `!allAppliedFilterKeysInLocalPinnedFilters` will always be `true`. To avoid this, we should only try to make the local pinned filters match if we actually have any applied filters - and it's not `undefined`. Found this while trying to bump to `v11.20.0`. This was introduced in: * #10566
4feb30f
to
4bdd9d2
Compare
@mrcthms 👋 hey there - thanks for the review. First time contributing to Polaris, do I just squash and merge? How does this end up eventually in the package, is that all automatic? Anything for me to be aware of? |
@maael Yeah, you can squash and merge, and Polaris will automatically merge this into the next release branch. You should see a PR in the Polaris PR list called "Version Packages" and once the merge has completed, you'll see your change in that branch. To release a new version of It's worth noting that I'm going to be refactoring the Filters component quite a bit, and removing everything within the |
Sounds good, thanks for the info! I'll merge this then, and I'll leave it for another person to ship the |
…Shopify#10711) ### WHY are these changes introduced? Currently `appliedFilters` can be `undefined`, except when it is when we try to `setLocalPinnedFilters`, we'll do so forever because we fail the check to decide whether to try set state or not every time, as `!allAppliedFilterKeysInLocalPinnedFilters` will always be `true`. To avoid this, we should only try to make the local pinned filters match if we actually have any applied filters - and it's not `undefined`. Found this while trying to bump to `v11.20.0` from `v11.19.0`. This was introduced in: * Shopify#10566 ### WHAT is this pull request doing? Checking `appliedFilters` is `defined` before trying to `setLocalPinnedFilters`. ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) Example test that shows a bunch of re-renders ```tsx import React from 'react'; import {render} from '@testing-library/react'; import {Filters, PolarisTestProvider} from '@shopify/polaris'; function Test() { return ( <PolarisTestProvider> <Filters filters={[]} /> </PolarisTestProvider> ); } describe('Testing', () => { it('does thing', () => { render(<Test />); }); }); ``` <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
WHY are these changes introduced?
Currently
appliedFilters
can beundefined
, except when it is when we try tosetLocalPinnedFilters
, we'll do so forever because we fail the check to decide whether to try set state or not every time, as!allAppliedFilterKeysInLocalPinnedFilters
will always betrue
.To avoid this, we should only try to make the local pinned filters match if we actually have any applied filters - and it's not
undefined
.Found this while trying to bump to
v11.20.0
fromv11.19.0
.This was introduced in:
appliedFilters
prop don't get respected #10566WHAT is this pull request doing?
Checking
appliedFilters
isdefined
before trying tosetLocalPinnedFilters
.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Example test that shows a bunch of re-renders
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes