-
Notifications
You must be signed in to change notification settings - Fork 0
fix: only derive results summary name from location/countryCode #877
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
Conversation
… countryCode fields This was causing unusual behavior where adding Open Now > selecting a distance causing the first filter to be the Open Now filter, so the text was "13 locations near "Open Now"". That's obviously ridiculous. J=WAT-5188 TEST=manual https://jam.dev/c/2420ac58-7bc2-4834-85d0-783cc380ca4a
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
WalkthroughThe Locator component's logic for choosing a static filter displayName was changed. Previously it used the first static filter's displayName unconditionally. Now it searches static filters for one with kind "fieldValue" and a fieldId equal to LOCATION_FIELD or COUNTRY_CODE_FIELD, and uses that matched filter's displayName (using optional chaining for safety). Sequence Diagram(s)sequenceDiagram
autonumber
participant Locator
participant State as state.filters.static
Note over Locator,State#dff0d8: Previous flow
Locator->>State: read first filter [0]
State-->>Locator: filter0
Locator->>Locator: use filter0.displayName
Note over Locator,State#f0dfdf: New flow
Locator->>State: state.filters.static.filter(f => f.kind=="fieldValue" && (f.fieldId==LOCATION_FIELD || f.fieldId==COUNTRY_CODE_FIELD))
State-->>Locator: matchedFilters (array)
Locator->>Locator: use matchedFilters[0]?.displayName
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-10-29T22:00:03.843ZApplied to files:
🔇 Additional comments (1)
Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/visual-editor/src/components/Locator.tsx (1)
703-711: Fix correctly addresses the issue.The logic properly filters for location/countryCode filters to derive the display name, preventing "Open Now" from being incorrectly used in the results summary.
Consider using
find()instead offilter()[0]for slightly better readability and performance:const filterDisplayName = useSearchState( (state) => - state.filters?.static?.filter( + state.filters?.static?.find( (filter) => filter.filter.kind === "fieldValue" && (filter.filter.fieldId === LOCATION_FIELD || filter.filter.fieldId === COUNTRY_CODE_FIELD) - )[0]?.displayName + )?.displayName );
find()stops at the first match rather than iterating through the entire array.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/visual-editor/src/components/Locator.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-29T22:00:03.843Z
Learnt from: mkouzel-yext
Repo: yext/visual-editor PR: 833
File: packages/visual-editor/src/components/Locator.tsx:1050-1057
Timestamp: 2025-10-29T22:00:03.843Z
Learning: In packages/visual-editor/src/components/Locator.tsx, the AppliedFilters component is intentionally rendered in two locations (inside the filter modal and outside it) as per the design requirements. This dual rendering should not be flagged as a duplicate issue.
Applied to files:
packages/visual-editor/src/components/Locator.tsx
Better semantics
This was causing unusual behavior where adding Open Now > selecting a distance causing the first filter to be the Open Now filter, so the text in the result summary was "13 locations near "Open Now"". That's obviously ridiculous.
J=WAT-5188
TEST=manual
https://jam.dev/c/2420ac58-7bc2-4834-85d0-783cc380ca4a