feat: add option to show both distances in locator cards - #1281
Conversation
|
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (25)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe locator now supports a Sequence Diagram(s)sequenceDiagram
participant Locator
participant LocatorWrapper
participant LocatorResultCard
Locator->>LocatorWrapper: Select bothDistances
LocatorWrapper->>LocatorResultCard: Pass searchLocationName
LocatorResultCard->>LocatorResultCard: Format search and user distances
LocatorResultCard->>LocatorResultCard: Render localized distance content
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ 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 (1)
packages/visual-editor/src/components/locator/LocatorResultCard.tsx (1)
862-876: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting a shared distance-formatting helper.
displayDistance,searchDistance, anduserDistanceall repeat the sameformatDistance(fromMeters(meters, unit), i18n.language)} ${unitLabel}pattern. Extract a small helper, for exampleformatDistanceLabel(meters: number | undefined): string | undefined, and call it three times. This removes duplication and keeps the formatting rule in one place if it changes later.♻️ Proposed refactor
- const displayDistance = - typeof distance === "number" - ? `${formatDistance(fromMeters(distance, unit), i18n.language)} ${unitLabel}` - : undefined; - const searchDistance = - typeof result.distanceFromFilter === "number" - ? `${formatDistance( - fromMeters(result.distanceFromFilter, unit), - i18n.language - )} ${unitLabel}` - : undefined; - const userDistance = - typeof result.distance === "number" - ? `${formatDistance(fromMeters(result.distance, unit), i18n.language)} ${unitLabel}` - : undefined; + const formatDistanceLabel = (meters: number | undefined) => + typeof meters === "number" + ? `${formatDistance(fromMeters(meters, unit), i18n.language)} ${unitLabel}` + : undefined; + const displayDistance = formatDistanceLabel(distance); + const searchDistance = formatDistanceLabel(result.distanceFromFilter); + const userDistance = formatDistanceLabel(result.distance);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/visual-editor/src/components/locator/LocatorResultCard.tsx` around lines 862 - 876, Extract the repeated distance-label formatting from the surrounding component into a shared formatDistanceLabel helper accepting number | undefined and returning string | undefined. Reuse it for displayDistance, searchDistance, and userDistance, preserving the existing unit conversion, localization, and unitLabel output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/visual-editor/locales/components/zh/visual-editor.json`:
- Around line 30-32: Update the Chinese locale entries
distanceFromSearchLocation and distanceFromYou to own complete phrases with a
distance placeholder, then update LocatorResultCard.tsx to pass the formatted
distance when rendering them instead of prepending searchDistance/userDistance.
Add a zh bothDistances assertion covering the rendered distance phrases.
In `@packages/visual-editor/locales/platform/cs/visual-editor.json`:
- Line 308: Update the bothDistances locale value to use sentence case: change
the common noun to lowercase while preserving the existing Czech wording.
In `@packages/visual-editor/locales/platform/hu/visual-editor.json`:
- Line 156: Update the Hungarian distanceFromSearchLocation translation in both
platform and component visual-editor locale files to include the origin
preposition, rendering “od {{searchLocation}}” instead of only the location
placeholder.
---
Nitpick comments:
In `@packages/visual-editor/src/components/locator/LocatorResultCard.tsx`:
- Around line 862-876: Extract the repeated distance-label formatting from the
surrounding component into a shared formatDistanceLabel helper accepting number
| undefined and returning string | undefined. Reuse it for displayDistance,
searchDistance, and userDistance, preserving the existing unit conversion,
localization, and unitLabel output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3b9759cf-4e3e-4327-83f9-a5f901af67d9
📒 Files selected for processing (55)
packages/visual-editor/locales/components/cs/visual-editor.jsonpackages/visual-editor/locales/components/da/visual-editor.jsonpackages/visual-editor/locales/components/de/visual-editor.jsonpackages/visual-editor/locales/components/en-GB/visual-editor.jsonpackages/visual-editor/locales/components/en/visual-editor.jsonpackages/visual-editor/locales/components/es/visual-editor.jsonpackages/visual-editor/locales/components/et/visual-editor.jsonpackages/visual-editor/locales/components/fi/visual-editor.jsonpackages/visual-editor/locales/components/fr/visual-editor.jsonpackages/visual-editor/locales/components/hr/visual-editor.jsonpackages/visual-editor/locales/components/hu/visual-editor.jsonpackages/visual-editor/locales/components/it/visual-editor.jsonpackages/visual-editor/locales/components/ja/visual-editor.jsonpackages/visual-editor/locales/components/lt/visual-editor.jsonpackages/visual-editor/locales/components/lv/visual-editor.jsonpackages/visual-editor/locales/components/nb/visual-editor.jsonpackages/visual-editor/locales/components/nl/visual-editor.jsonpackages/visual-editor/locales/components/pl/visual-editor.jsonpackages/visual-editor/locales/components/pt/visual-editor.jsonpackages/visual-editor/locales/components/ro/visual-editor.jsonpackages/visual-editor/locales/components/sk/visual-editor.jsonpackages/visual-editor/locales/components/sv/visual-editor.jsonpackages/visual-editor/locales/components/tr/visual-editor.jsonpackages/visual-editor/locales/components/zh-TW/visual-editor.jsonpackages/visual-editor/locales/components/zh/visual-editor.jsonpackages/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/Locator.test.tsxpackages/visual-editor/src/components/locator/Locator.tsxpackages/visual-editor/src/components/locator/LocatorResultCard.tsxpackages/visual-editor/src/components/locator/LocatorWrapper.tsxpackages/visual-editor/src/docs/components.md
auto-screenshot-update: true
…al-editor into locator-both-distances
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/visual-editor/locales/platform/pt/visual-editor.json`:
- Line 155: Update the distanceLineFromSearch translation to use an idiomatic
Portuguese origin phrase, replacing “da pesquisa” with wording such as “do local
pesquisado” while preserving the existing distance placeholder and markup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4ec1e5a5-8ee9-4de1-88fc-00f92dd7020a
⛔ Files ignored due to path filters (21)
packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] latest version default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] latest version multi-pageset default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] latest version non-default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 24 with filters.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 60 custom heading with site color 2.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 60 custom heading.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 60 custom title and result cards with site color 3.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 64 static headings.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 64 static image.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] version 74 comingSoon.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] latest version default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] latest version multi-pageset default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] latest version non-default props.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 24 with filters.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 60 custom heading with site color 2.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 60 custom heading.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 60 custom title and result cards with site color 3.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 64 static headings.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 64 static image.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/Locator/[tablet] version 74 comingSoon.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**packages/visual-editor/src/components/testing/screenshots/PhotoGallerySection/[desktop] version 59 with showSectionHeading false.pngis excluded by!**/*.png,!packages/visual-editor/src/components/testing/screenshots/**
📒 Files selected for processing (52)
packages/visual-editor/locales/components/cs/visual-editor.jsonpackages/visual-editor/locales/components/da/visual-editor.jsonpackages/visual-editor/locales/components/de/visual-editor.jsonpackages/visual-editor/locales/components/en-GB/visual-editor.jsonpackages/visual-editor/locales/components/en/visual-editor.jsonpackages/visual-editor/locales/components/es/visual-editor.jsonpackages/visual-editor/locales/components/et/visual-editor.jsonpackages/visual-editor/locales/components/fi/visual-editor.jsonpackages/visual-editor/locales/components/fr/visual-editor.jsonpackages/visual-editor/locales/components/hr/visual-editor.jsonpackages/visual-editor/locales/components/hu/visual-editor.jsonpackages/visual-editor/locales/components/it/visual-editor.jsonpackages/visual-editor/locales/components/ja/visual-editor.jsonpackages/visual-editor/locales/components/lt/visual-editor.jsonpackages/visual-editor/locales/components/lv/visual-editor.jsonpackages/visual-editor/locales/components/nb/visual-editor.jsonpackages/visual-editor/locales/components/nl/visual-editor.jsonpackages/visual-editor/locales/components/pl/visual-editor.jsonpackages/visual-editor/locales/components/pt/visual-editor.jsonpackages/visual-editor/locales/components/ro/visual-editor.jsonpackages/visual-editor/locales/components/sk/visual-editor.jsonpackages/visual-editor/locales/components/sv/visual-editor.jsonpackages/visual-editor/locales/components/tr/visual-editor.jsonpackages/visual-editor/locales/components/zh-TW/visual-editor.jsonpackages/visual-editor/locales/components/zh/visual-editor.jsonpackages/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/Locator.test.tsxpackages/visual-editor/src/components/locator/LocatorResultCard.tsx
🚧 Files skipped from review as they are similar to previous changes (50)
- packages/visual-editor/locales/components/fr/visual-editor.json
- packages/visual-editor/locales/components/hu/visual-editor.json
- packages/visual-editor/locales/platform/fi/visual-editor.json
- packages/visual-editor/locales/platform/ro/visual-editor.json
- packages/visual-editor/locales/components/ja/visual-editor.json
- packages/visual-editor/locales/platform/en/visual-editor.json
- packages/visual-editor/locales/components/nl/visual-editor.json
- packages/visual-editor/locales/components/en/visual-editor.json
- packages/visual-editor/locales/platform/lt/visual-editor.json
- packages/visual-editor/locales/platform/hr/visual-editor.json
- packages/visual-editor/locales/components/sk/visual-editor.json
- packages/visual-editor/locales/components/de/visual-editor.json
- packages/visual-editor/locales/components/pt/visual-editor.json
- packages/visual-editor/locales/components/cs/visual-editor.json
- packages/visual-editor/locales/platform/pl/visual-editor.json
- packages/visual-editor/locales/components/hr/visual-editor.json
- packages/visual-editor/locales/platform/cs/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/components/pl/visual-editor.json
- packages/visual-editor/locales/components/tr/visual-editor.json
- packages/visual-editor/locales/components/en-GB/visual-editor.json
- packages/visual-editor/locales/components/it/visual-editor.json
- packages/visual-editor/locales/components/sv/visual-editor.json
- packages/visual-editor/locales/components/nb/visual-editor.json
- packages/visual-editor/locales/platform/fr/visual-editor.json
- packages/visual-editor/locales/components/lt/visual-editor.json
- packages/visual-editor/locales/components/fi/visual-editor.json
- packages/visual-editor/locales/components/zh-TW/visual-editor.json
- packages/visual-editor/locales/platform/ja/visual-editor.json
- packages/visual-editor/locales/components/lv/visual-editor.json
- packages/visual-editor/locales/components/da/visual-editor.json
- packages/visual-editor/locales/platform/sk/visual-editor.json
- packages/visual-editor/locales/components/es/visual-editor.json
- packages/visual-editor/locales/platform/es/visual-editor.json
- packages/visual-editor/locales/components/ro/visual-editor.json
- packages/visual-editor/locales/platform/it/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/zh/visual-editor.json
- packages/visual-editor/locales/platform/nl/visual-editor.json
- packages/visual-editor/locales/components/et/visual-editor.json
- packages/visual-editor/locales/components/zh/visual-editor.json
- packages/visual-editor/locales/platform/lv/visual-editor.json
- packages/visual-editor/locales/platform/et/visual-editor.json
- packages/visual-editor/locales/platform/en-GB/visual-editor.json
- packages/visual-editor/locales/platform/nb/visual-editor.json
- packages/visual-editor/src/components/locator/LocatorResultCard.tsx
- packages/visual-editor/locales/platform/hu/visual-editor.json
This adds a new "Both Distances" option to the Distance Display field in the OOTB locator. When this option is selected, the distance from the card's location to the searched location is shown first, followed by the distance from the card's location to the user, both with labels as shown in the screenshots below. The other Distance Display options are unaffected.
This also fixes two minor styling bugs:
Desktop:

Mobile:
