Conversation
WalkthroughThis 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
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (31)
packages/visual-editor/locales/platform/cs/visual-editor.jsonpackages/visual-editor/locales/platform/da/visual-editor.jsonpackages/visual-editor/locales/platform/de/visual-editor.jsonpackages/visual-editor/locales/platform/en-GB/visual-editor.jsonpackages/visual-editor/locales/platform/en/visual-editor.jsonpackages/visual-editor/locales/platform/es/visual-editor.jsonpackages/visual-editor/locales/platform/et/visual-editor.jsonpackages/visual-editor/locales/platform/fi/visual-editor.jsonpackages/visual-editor/locales/platform/fr/visual-editor.jsonpackages/visual-editor/locales/platform/hr/visual-editor.jsonpackages/visual-editor/locales/platform/hu/visual-editor.jsonpackages/visual-editor/locales/platform/it/visual-editor.jsonpackages/visual-editor/locales/platform/ja/visual-editor.jsonpackages/visual-editor/locales/platform/lt/visual-editor.jsonpackages/visual-editor/locales/platform/lv/visual-editor.jsonpackages/visual-editor/locales/platform/nb/visual-editor.jsonpackages/visual-editor/locales/platform/nl/visual-editor.jsonpackages/visual-editor/locales/platform/pl/visual-editor.jsonpackages/visual-editor/locales/platform/pt/visual-editor.jsonpackages/visual-editor/locales/platform/ro/visual-editor.jsonpackages/visual-editor/locales/platform/sk/visual-editor.jsonpackages/visual-editor/locales/platform/sv/visual-editor.jsonpackages/visual-editor/locales/platform/tr/visual-editor.jsonpackages/visual-editor/locales/platform/zh-TW/visual-editor.jsonpackages/visual-editor/locales/platform/zh/visual-editor.jsonpackages/visual-editor/src/components/Locator.test.tsxpackages/visual-editor/src/components/Locator.tsxpackages/visual-editor/src/components/LocatorResultCard.tsxpackages/visual-editor/src/components/migrations/0065_locator_distance_display.tspackages/visual-editor/src/components/migrations/migrationRegistry.tspackages/visual-editor/src/docs/components.md
packages/visual-editor/locales/platform/zh-TW/visual-editor.json
Outdated
Show resolved
Hide resolved
|
|
||
| | Prop | Type | Description | Default | | ||
| | :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------- | :------------------------------------- | | ||
| | `distanceDisplay` | `DistanceDisplayOption` | Controls which distance value to display on each locator result card. | | |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (3)
packages/visual-editor/src/components/Locator.test.tsxpackages/visual-editor/src/components/Locator.tsxpackages/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
Allows users to set one of three options for the distance shown in locator search results:
If using distance from search, we will use the
distanceFromFilterfield 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 Areabutton to the top of the map rather than the bottom.J=WAT-5416