Skip to content

feat: distance setting for locators#1076

Open
k-gerner wants to merge 8 commits intomainfrom
locator-distance-from-filter
Open

feat: distance setting for locators#1076
k-gerner wants to merge 8 commits intomainfrom
locator-distance-from-filter

Conversation

@k-gerner
Copy link
Contributor

@k-gerner k-gerner commented Mar 3, 2026

Allows users to set one of three options for the distance shown in locator search results:

  • Distance from user (default)
  • Distance from search
  • Hidden

If using distance from search, we will use the distanceFromFilter field that is included in the search API response, which indicates how far the result is from the specified location searched.

Additionally, moves the Search This Area button to the top of the map rather than the bottom.

J=WAT-5416

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

Walkthrough

This PR adds a distanceDisplay configuration to the Locator feature: new DistanceDisplayOption type ("distanceFromUser" | "distanceFromSearch" | "hidden"), a distanceDisplay prop on Locator and LocatorResultCard (default "distanceFromUser"), wiring of the prop through Locator -> internal renderer -> card, updates to tests and many locale JSONs, a migration to set a default for existing Locator instances, and docs updates describing the new prop and resultCard fields.

Sequence Diagram(s)

sequenceDiagram
  participant Editor as Visual Editor (config)
  participant Locator as LocatorComponent
  participant Internal as LocatorInternal
  participant Card as CardComponent
  participant ResultCard as LocatorResultCard

  Editor->>Locator: provide props (distanceDisplay)
  Locator->>Internal: render with distanceDisplay
  Internal->>Card: create CardComponent(distanceDisplay)
  Card->>ResultCard: render LocatorResultCard(distanceDisplay)
  ResultCard->>ResultCard: compute/display distance based on distanceDisplay
Loading

Possibly related PRs

Suggested labels

create-dev-release

Suggested reviewers

  • mkilpatrick
  • benlife5
  • asanehisa
  • mkouzel-yext
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: distance setting for locators' clearly and concisely describes the main feature addition: a configurable distance setting for locator components.
Description check ✅ Passed The description is directly related to the changeset, explaining the distance display options, the search API integration, and the button repositioning that are all reflected in the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch locator-distance-from-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 3

🧹 Nitpick comments (2)
packages/visual-editor/locales/platform/es/visual-editor.json (2)

337-337: Consider feminine agreement for “hidden” option label.

Since this option controls “distancia” (feminine noun), “Oculta” is a more natural adjective than “Oculto”.

Suggested wording tweak
-      "hidden": "Oculto",
+      "hidden": "Oculta",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/locales/platform/es/visual-editor.json` at line 337,
Update the Spanish localization value for the "hidden" key in
packages/visual-editor/locales/platform/es/visual-editor.json from "Oculto" to
the feminine form "Oculta" so it agrees with the feminine noun it describes
(e.g., "distancia"); locate the "hidden" property in that JSON and replace its
string value accordingly.

290-291: Use parallel phrasing for both distance option labels.

Line 290 uses “desde…”, but Line 291 uses “del…”. Keeping both as “desde” reads more consistently in the same dropdown.

Suggested wording tweak
       "distanceFromSearch": "Distancia desde la búsqueda",
-      "distanceFromUser": "Distancia del usuario",
+      "distanceFromUser": "Distancia desde el usuario",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/locales/platform/es/visual-editor.json` around lines
290 - 291, The two localization keys distanceFromSearch and distanceFromUser use
inconsistent prepositions; change the value for distanceFromUser from "Distancia
del usuario" to match the phrasing of distanceFromSearch, e.g. "Distancia desde
el usuario", so both dropdown options use parallel "desde…" phrasing; update the
JSON value for the distanceFromUser key accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/visual-editor/locales/platform/zh-TW/visual-editor.json`:
- Line 337: Update the JSON value for the "hidden" key (currently "隱") to the
full translation "隱藏" to match the existing "hide": "隱藏" entry so the dropdown
label is not truncated and remains consistent.

In `@packages/visual-editor/locales/platform/zh/visual-editor.json`:
- Line 337: Update the truncated translation for the "hidden" key in the
visual-editor locale JSON: replace the value "隐" with the full wording "隐藏" to
match the existing "hide": "隐藏" entry and ensure consistent, non-confusing UI
text for the "hidden" option.

In `@packages/visual-editor/src/docs/components.md`:
- Line 548: The docs table omits the default for the distanceDisplay prop;
update the documentation row for `distanceDisplay` in components.md to show the
real default value `"distanceFromUser"`, since the implementation in Locator.tsx
(prop default/initialization for distanceDisplay) and the migration file
migrations/0065_locator_distance_display.ts both indicate that default. Ensure
the Default column contains "distanceFromUser" and optionally add a brief note
linking the default to the Locator component behavior.

---

Nitpick comments:
In `@packages/visual-editor/locales/platform/es/visual-editor.json`:
- Line 337: Update the Spanish localization value for the "hidden" key in
packages/visual-editor/locales/platform/es/visual-editor.json from "Oculto" to
the feminine form "Oculta" so it agrees with the feminine noun it describes
(e.g., "distancia"); locate the "hidden" property in that JSON and replace its
string value accordingly.
- Around line 290-291: The two localization keys distanceFromSearch and
distanceFromUser use inconsistent prepositions; change the value for
distanceFromUser from "Distancia del usuario" to match the phrasing of
distanceFromSearch, e.g. "Distancia desde el usuario", so both dropdown options
use parallel "desde…" phrasing; update the JSON value for the distanceFromUser
key accordingly.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60588ea and 8b03ad7.

📒 Files selected for processing (31)
  • packages/visual-editor/locales/platform/cs/visual-editor.json
  • packages/visual-editor/locales/platform/da/visual-editor.json
  • packages/visual-editor/locales/platform/de/visual-editor.json
  • packages/visual-editor/locales/platform/en-GB/visual-editor.json
  • packages/visual-editor/locales/platform/en/visual-editor.json
  • packages/visual-editor/locales/platform/es/visual-editor.json
  • packages/visual-editor/locales/platform/et/visual-editor.json
  • packages/visual-editor/locales/platform/fi/visual-editor.json
  • packages/visual-editor/locales/platform/fr/visual-editor.json
  • packages/visual-editor/locales/platform/hr/visual-editor.json
  • packages/visual-editor/locales/platform/hu/visual-editor.json
  • packages/visual-editor/locales/platform/it/visual-editor.json
  • packages/visual-editor/locales/platform/ja/visual-editor.json
  • packages/visual-editor/locales/platform/lt/visual-editor.json
  • packages/visual-editor/locales/platform/lv/visual-editor.json
  • packages/visual-editor/locales/platform/nb/visual-editor.json
  • packages/visual-editor/locales/platform/nl/visual-editor.json
  • packages/visual-editor/locales/platform/pl/visual-editor.json
  • packages/visual-editor/locales/platform/pt/visual-editor.json
  • packages/visual-editor/locales/platform/ro/visual-editor.json
  • packages/visual-editor/locales/platform/sk/visual-editor.json
  • packages/visual-editor/locales/platform/sv/visual-editor.json
  • packages/visual-editor/locales/platform/tr/visual-editor.json
  • packages/visual-editor/locales/platform/zh-TW/visual-editor.json
  • packages/visual-editor/locales/platform/zh/visual-editor.json
  • packages/visual-editor/src/components/Locator.test.tsx
  • packages/visual-editor/src/components/Locator.tsx
  • packages/visual-editor/src/components/LocatorResultCard.tsx
  • packages/visual-editor/src/components/migrations/0065_locator_distance_display.ts
  • packages/visual-editor/src/components/migrations/migrationRegistry.ts
  • packages/visual-editor/src/docs/components.md


| Prop | Type | Description | Default |
| :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------- | :------------------------------------- |
| `distanceDisplay` | `DistanceDisplayOption` | Controls which distance value to display on each locator result card. | |
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Document the real default for distanceDisplay.

The Default column is blank, but implementation defaults this to "distanceFromUser" (see packages/visual-editor/src/components/Locator.tsx Line 631, plus migration backfill in packages/visual-editor/src/components/migrations/0065_locator_distance_display.ts).

📝 Suggested docs patch
-| `distanceDisplay`             | `DistanceDisplayOption`                                                                                                                                                            | Controls which distance value to display on each locator result card.                        |                                        |
+| `distanceDisplay`             | `DistanceDisplayOption`                                                                                                                                                            | Controls which distance value to display on each locator result card.                        | `"distanceFromUser"`                   |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/src/docs/components.md` at line 548, The docs table
omits the default for the distanceDisplay prop; update the documentation row for
`distanceDisplay` in components.md to show the real default value
`"distanceFromUser"`, since the implementation in Locator.tsx (prop
default/initialization for distanceDisplay) and the migration file
migrations/0065_locator_distance_display.ts both indicate that default. Ensure
the Default column contains "distanceFromUser" and optionally add a brief note
linking the default to the Locator component behavior.

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.

🧹 Nitpick comments (1)
packages/visual-editor/src/components/Locator.tsx (1)

98-98: Consider adding an explicit type annotation for type safety.

While TypeScript infers "distanceFromUser" as a literal type, an explicit annotation would catch invalid values at compile time if the constant is modified.

🔧 Suggested improvement
-const DEFAULT_DISTANCE_DISPLAY = "distanceFromUser";
+const DEFAULT_DISTANCE_DISPLAY: DistanceDisplayOption = "distanceFromUser";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/src/components/Locator.tsx` at line 98,
DEFAULT_DISTANCE_DISPLAY is declared without an explicit type; add a type
annotation to the constant (e.g., a string literal or a union of allowed display
keys) so TypeScript will catch invalid assignments at compile time. Locate
DEFAULT_DISTANCE_DISPLAY in Locator.tsx and change its declaration to include
the appropriate type (for example: declare as "distanceFromUser" literal type or
a union like "distanceFromUser" | "otherOption") to enforce type safety across
uses such as functions or props that consume this constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/visual-editor/src/components/Locator.tsx`:
- Line 98: DEFAULT_DISTANCE_DISPLAY is declared without an explicit type; add a
type annotation to the constant (e.g., a string literal or a union of allowed
display keys) so TypeScript will catch invalid assignments at compile time.
Locate DEFAULT_DISTANCE_DISPLAY in Locator.tsx and change its declaration to
include the appropriate type (for example: declare as "distanceFromUser" literal
type or a union like "distanceFromUser" | "otherOption") to enforce type safety
across uses such as functions or props that consume this constant.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52329ef and 94f80ed.

📒 Files selected for processing (3)
  • packages/visual-editor/src/components/Locator.test.tsx
  • packages/visual-editor/src/components/Locator.tsx
  • packages/visual-editor/src/components/LocatorResultCard.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/visual-editor/src/components/Locator.test.tsx

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.

2 participants