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: avoids remounting #13567
fix: avoids remounting #13567
Conversation
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.
Do you have an idea on how to update the filter state upon a simple route change? If I recall correctly, the issue is that the ArtworkFilterContextProvider uses the props to initialize the filter store but then does not update the store when the props change.
@olerichter00 I've seriously considered just rewriting the filters component to avoid having to fix anything in it 😆 — I'm not sure. If we can just update the internal state whenever the route changes, using an effect, that'd be great though there might be some complications with a recursive effect loop. |
// Setting the key here to enforce a remount of the component when changing pages or query parameter filters within the query. | ||
key={match.location.pathname + match.location.search} |
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.
I'm not sure if I understand correctly why this causes the flashing images. Is it because forcing the ArtworkFilterContextProvider
with the key
prop also remounts it's children?
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.
Yeah, key will forcibly re-render the component and anything under it. That means images will be re-loaded.
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.
Thanks, then adding a key here is indeed not a good idea.
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.
Ah @dzucconi - this was the same issue that fixed things before, I (think).
Re URL state -- yep, driving by URL state, we've been talking about this for a while. It seems straight forward 🤷
Closes DIA-456
Re: #13214 — this bug needs to be fixed rather than papered over by constantly remounting the filter whenever the route changes.
It's actually pretty concerning that one can't drive the filters with a simple route change. One would think that would be the primary way we'd change filter state...