-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(ui): relationship filter renders stale values when changing fields #11080
Merged
jacobsfletch
merged 19 commits into
main
from
fix/changing-condition-field-should-update-values
Feb 11, 2025
Merged
fix(ui): relationship filter renders stale values when changing fields #11080
jacobsfletch
merged 19 commits into
main
from
fix/changing-condition-field-should-update-values
Feb 11, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c6c2ed0
to
dec85c4
Compare
🚀 This is included in version v3.23.0 |
jacobsfletch
added a commit
that referenced
this pull request
Feb 11, 2025
…11008) Fixes #10440. When `filterOptions` are set on a relationship field, those same filters are not applied to the `Filter` component within the list view. This is because `filterOptions` is not being thread into the `RelationshipFilter` component responsible for populating the available options. To do this, we first need to be resolve the filter options on the server as they accept functions. Once resolved, they can be prop-drilled into the proper component and appended onto the client-side "where" query. Reliant on #11080.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9873. The relationship filter in the "where" builder renders stale values when switching between fields or adding additional "and" conditions. This was because the
RelationshipFilter
component was not responding to changes in therelationTo
prop and failing to reset internal state when these events took place.While it sounds like a simple fix, it was actually quite extensive. The
RelationshipFilter
component was previously relying on auseEffect
that had a callback in its dependencies. This was causing the effect to run uncontrollably using old references. To avoid this, we use the newuseEffectEvent
approach which allows the underlying effect to run much more precisely. Same with theCondition
component that wraps it. We now run callbacks directly within event handlers as much as possible, and rely onuseEffectEvent
only for debounced value changes.This component was also unnecessarily complex...and still is to some degree. Previously, it was maintaining two separate refs, one to track the relationships that have yet to fully load, and another to track the next pages of each relationship that need to load on the next run. These have been combined into a single ref that tracks both simultaneously, as this data is interrelated.
This change also does some much needed housekeeping to the
WhereBuilder
by improving types, defaulting the operator field, etc.Related: #11023 and #11032
Unrelated: finds a few more instances where the new
addListFilter
helper from #11026 could be used. Also removes a few duplicative tests.