Skip to content

feat: make showing distance options in filters modal a toggleable prop#866

Merged
mkouzel-yext merged 8 commits intomainfrom
hide-distance-options-locator
Nov 5, 2025
Merged

feat: make showing distance options in filters modal a toggleable prop#866
mkouzel-yext merged 8 commits intomainfrom
hide-distance-options-locator

Conversation

@mkouzel-yext
Copy link
Contributor

@mkouzel-yext mkouzel-yext commented Nov 5, 2025

Adds a field in the locator settings panel to show or not show distance options that set the radius of any applied near filters.

J=WAT-5141
TEST=manual

jam:https://jam.dev/c/9fe6b4f6-8df1-4871-816e-c88186482681

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 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 5, 2025

Walkthrough

The Locator component adds a new filters field showDistanceOptions: boolean (default false). When true, the UI renders distance controls and LocatorInternal/FilterModal apply or overwrite Near filter radius from selected distance options; when false, DistanceFilter is hidden and existing filterValue.radius is preserved. LocatorFields, LocatorComponent.defaultProps, FilterModalProps, and handlers (e.g., handleFilterSelect, initial location/radius logic) were updated to accept and forward showDistanceOptions and to conditionally control distance-related behavior.

Sequence Diagram(s)

sequenceDiagram
  participant App as LocatorComponent
  participant Internal as LocatorInternal
  participant Modal as FilterModal
  participant Distance as DistanceFilter
  participant Store as FilterState

  App->>Internal: mount(filters { showDistanceOptions })
  Internal->>Modal: open(filterProps + showDistanceOptions)
  alt showDistanceOptions = true
    Modal->>Distance: render DistanceFilter
    Distance-->>Modal: selectedDistanceMiles
    Modal->>Internal: applyFilter(selectedDistanceMiles)
    Internal->>Store: merge Near filter (radius = selectedDistanceMiles)
  else showDistanceOptions = false
    Modal-->>Distance: not rendered
    Modal->>Internal: applyFilter(no distance change)
    Internal->>Store: merge Near filter (radius = previousRadius)
  end

  Note over Internal,Store: initial location updates and handleFilterSelect\nuse showDistanceOptions to decide whether to overwrite radius
Loading

Possibly related PRs

Suggested reviewers

  • mkilpatrick
  • benlife5
  • colton-demetriou

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a toggleable prop to control the display of distance options in the filters modal.
Description check ✅ Passed The description is related to the changeset, explaining that a field is added to toggle distance options in the locator settings panel with a reference to the Jira ticket.
✨ 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 hide-distance-options-locator

📜 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 6e67945 and 68f9721.

📒 Files selected for processing (1)
  • packages/visual-editor/src/vite-plugin/defaultLayoutData.ts (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/vite-plugin/defaultLayoutData.ts
🔇 Additional comments (1)
packages/visual-editor/src/vite-plugin/defaultLayoutData.ts (1)

1506-1509: LGTM! New filter configuration property added correctly.

The addition of showDistanceOptions: false to the locator filters configuration is correct and appropriately placed. The default value of false ensures backward compatibility by keeping distance options hidden unless explicitly enabled, which is a safe choice for this new toggleable feature.


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)

1007-1032: Note: selectedDistanceMiles state is disconnected from filter behavior.

Line 1032 resets selectedDistanceMiles to DEFAULT_RADIUS_MILES, but this value is no longer used when constructing the location filter (lines 1011-1015 omit the radius field). This state management appears to be preserved for when the distance filter UI is re-enabled in the future.

Consider adding a comment explaining this intentional disconnection, or remove the state management at line 1032 if the feature won't be re-enabled.

    searchActions.setStaticFilters(
      unaffectedStaticFilters.concat(
        updatedLocationFilters,
        updatedOpenNowFilters
      )
    );
    searchActions.resetFacets();
    // Execute search to update AppliedFilters components
    searchActions.setOffset(0);
    executeSearch(searchActions);
-   setSelectedDistanceMiles(DEFAULT_RADIUS_MILES);
+   // Note: selectedDistanceMiles state preserved for future when distance filter is re-enabled
+   setSelectedDistanceMiles(DEFAULT_RADIUS_MILES);
  };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 068bd24 and e3b165a.

📒 Files selected for processing (1)
  • packages/visual-editor/src/components/Locator.tsx (3 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 (3)
packages/visual-editor/src/components/Locator.tsx (3)

697-699: LGTM: Preserves radius from filter search.

The spread operator correctly preserves the radius (and other fields) from the filter search response, preventing unintended overwrites. This aligns with the PR objective.


1561-1617: LGTM: Clean implementation of conditional distance filter rendering.

The hidden prop implementation is well-structured:

  • Uses conditional rendering (!hidden && ...) instead of CSS hiding, which is better for accessibility
  • Preserves all functionality for future enablement
  • Includes accessible aria-label attributes on distance option buttons
  • Maintains state management infrastructure

The approach correctly hides the feature while keeping the implementation ready for future activation.


791-795: The review comment contradicts itself and mischaracterizes the code changes.

The snippet provided shows radius: selectedDistanceMiles * MILES_TO_METERS, is still present at line 794. The claim that "radius field removed from filter value" is incorrect—the radius is not removed in the final code state. The request to verify API behavior without radius is based on a false premise and should not be acted upon.

Likely an incorrect or invalid review comment.

@mkouzel-yext mkouzel-yext force-pushed the hide-distance-options-locator branch from e3b165a to e0c1ad2 Compare November 5, 2025 17:33
@mkouzel-yext mkouzel-yext changed the title fix: hide distance options in filters modal feat: make showing distance options in filters modal a toggleable prop for locator Nov 5, 2025
@mkouzel-yext mkouzel-yext changed the title feat: make showing distance options in filters modal a toggleable prop for locator feat: make showing distance options in filters modal a toggleable prop Nov 5, 2025
The distance options were included in the mocks but not actually intended to be implemented yet. For now we'll hide them, and decide whether to keep or remove later. Updates filter select and clear all handlers to not overwrite the radius found by filter search with the selected distance.
J=WAT-5141
TEST=manual

jam:https://jam.dev/c/0e818afa-73fc-4e79-afae-b0cf177169d3
@mkouzel-yext mkouzel-yext force-pushed the hide-distance-options-locator branch from 6c8fc5c to 278e07d Compare November 5, 2025 17:38
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)

1029-1040: Consider adding fallback for undefined radius.

The conditional logic correctly implements the feature intent. However, if previousValue?.radius is undefined when showDistanceOptions is false, the filter will have an undefined radius which could cause issues.

While the initial search always sets a radius, consider adding a fallback for defensive coding:

 const radius = showDistanceOptions
   ? DEFAULT_RADIUS_MILES * MILES_TO_METERS
-  : previousValue?.radius;
+  : previousValue?.radius ?? DEFAULT_RADIUS_MILES * MILES_TO_METERS;

This ensures the filter always has a valid radius value.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3b165a and 6c8fc5c.

📒 Files selected for processing (2)
  • packages/visual-editor/src/components/Locator.tsx (13 hunks)
  • packages/visual-editor/src/docs/components.md (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/docs/components.md
  • packages/visual-editor/src/components/Locator.tsx
🧬 Code graph analysis (1)
packages/visual-editor/src/components/Locator.tsx (1)
packages/visual-editor/src/editor/YextField.tsx (1)
  • YextField (163-284)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: call_unit_test / unit_tests (18.x)
  • GitHub Check: call_unit_test / unit_tests (20.x)
  • GitHub Check: semgrep/ci
🔇 Additional comments (11)
packages/visual-editor/src/docs/components.md (1)

431-435: LGTM!

The documentation correctly reflects the new showDistanceOptions prop with clear description and proper table formatting.

packages/visual-editor/src/components/Locator.tsx (10)

452-457: LGTM!

The prop definition is clear with appropriate JSDoc documentation and correct type definition.


515-524: LGTM!

The field definition follows established patterns and provides appropriate UI configuration for the toggle.


563-563: LGTM!

The default value correctly sets showDistanceOptions to false, matching the PR objective to hide distance options by default.


610-610: LGTM!

Proper destructuring of the new prop from the filters configuration.


708-720: Logic correctly implements feature with clear comment.

The conditional radius logic properly preserves the filter search radius when distance options are disabled. The inline comment clearly explains the intent.


1077-1078: LGTM!

Correctly updates the filter modal visibility logic to include the new distance options toggle.


1173-1173: LGTM!

Correctly passes the showDistanceOptions prop down to the FilterModal component.


1462-1462: LGTM!

The interface properly defines the new prop with a clear explanatory comment.


1475-1475: LGTM!

Proper destructuring of the new prop within the FilterModal component.


1519-1524: LGTM!

The conditional rendering correctly hides the DistanceFilter UI when showDistanceOptions is false, following the same pattern as the OpenNowFilter.

@mkouzel-yext mkouzel-yext requested a review from a team November 5, 2025 17:58
Copy link
Contributor

@benlife5 benlife5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkouzel-yext mkouzel-yext merged commit cf036a0 into main Nov 5, 2025
15 checks passed
@mkouzel-yext mkouzel-yext deleted the hide-distance-options-locator branch November 5, 2025 18:46
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