Skip to content

Conversation

@mkouzel-yext
Copy link
Contributor

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

… 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
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

The 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
Loading

Possibly related PRs

Suggested reviewers

  • benlife5
  • Fondryext
  • asanehisa

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: ensuring the results summary name derives only from location/countryCode filters.
Description check ✅ Passed The description explains the bug being fixed with a clear example and references the ticket, relating directly to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-results-summary-filter

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 802910e and 4957e63.

📒 Files selected for processing (1)
  • packages/visual-editor/src/components/Locator.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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.
📚 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
🔇 Additional comments (1)
packages/visual-editor/src/components/Locator.tsx (1)

704-710: LGTM! Targeted fix for results summary text.

The change correctly ensures that the results summary displays the location or country code filter name rather than inadvertently using other filter names (like "Open Now"). The .find() method with specific field ID checks guarantees the right filter is selected, and optional chaining safely handles cases where no location filter exists.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 of filter()[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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f3b28f and 802910e.

📒 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

@mkouzel-yext mkouzel-yext merged commit 8bc0c75 into main Nov 7, 2025
15 checks passed
@mkouzel-yext mkouzel-yext deleted the fix-results-summary-filter branch November 7, 2025 15:06
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.

3 participants