Skip to content

chore: split locator up into smaller files#1238

Open
anguyen-yext2 wants to merge 3 commits into
mainfrom
split-locator
Open

chore: split locator up into smaller files#1238
anguyen-yext2 wants to merge 3 commits into
mainfrom
split-locator

Conversation

@anguyen-yext2

Copy link
Copy Markdown
Contributor

J=WAT-5650
TEST=manual

@anguyen-yext2 anguyen-yext2 added the create-dev-release Triggers dev release workflow label Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown

commit: ab6b11f

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The monolithic Locator.tsx (2,676 lines) is removed and replaced with a locator/ subdirectory containing six focused modules. locatorUtils.ts provides shared constants, filter construction helpers, Maki icon loading, and coordinate utilities. LocatorFilters.tsx implements the filter modal with collapsible open-now and distance sub-sections. LocatorMap.tsx renders the Mapbox map with per-entity pin styling. LocatorResults.tsx exports the SearchState type and result count/listing components. LocatorWrapper.tsx wires all providers and orchestrates the full search lifecycle. Locator.tsx holds LocatorProps, the editor field schema, and LocatorComponent config. Barrel exports and internal imports are updated to reflect the new paths.

Possibly Related PRs

  • yext/visual-editor#1120: Both PRs share getConfiguredMapCenterOrDefault and LoadingMapPlaceholder logic for map initialization in the refactored locator implementation.
  • yext/visual-editor#1207: Both PRs touch the boolean field display-text subfields (type.boolean inputs) in the locator result card heading editor UI.
  • yext/visual-editor#1095: Both PRs involve getFacetFieldOptionsForEntityType for per-entity-type facet option generation in the locator editor schema.

Suggested Reviewers

  • jwartofsky-yext
  • asanehisa
  • mkouzel-yext
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: split locator up into smaller files' accurately describes the main change—a refactoring that reorganizes the monolithic Locator component into multiple focused modules organized in a dedicated directory.
Description check ✅ Passed The description references the associated Jira ticket (WAT-5650) and testing approach (manual), which is relevant context for the changeset even if minimal in detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split-locator

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

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

204-211: ⚡ Quick win

handleDrag should be wrapped in useCallback.

handleDrag is included in the mapProps dependency array (line 494), but it's not memoized. This causes mapProps to recalculate on every render, which could lead to unnecessary re-renders of LocatorMap.

♻️ Suggested fix
-  const handleDrag: OnDragHandler = (center, bounds) => {
+  const handleDrag: OnDragHandler = React.useCallback((center, bounds) => {
     setMapCenter({
       latitude: center.latitude,
       longitude: center.longitude,
     });
     setMapRadius(center.distanceTo(bounds.getNorthEast()));
     setShowSearchAreaButton(true);
-  };
+  }, []);

Also applies to: 483-500

🤖 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/LocatorWrapper.tsx` around
lines 204 - 211, The handleDrag function is used as a dependency in mapProps but
is not memoized, causing mapProps to recalculate on every render. Wrap the
handleDrag function definition with useCallback hook and include its
dependencies (setMapCenter, setMapRadius, setShowSearchAreaButton) in the
useCallback dependency array. This will ensure that handleDrag maintains
referential equality across renders unless its dependencies change, preventing
unnecessary recalculations of mapProps that includes handleDrag in its
definition around lines 483-500.
🤖 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/src/components/locator/locatorUtils.ts`:
- Around line 142-158: The parseMapStartingLocation function currently uses
parseFloat() which accepts malformed numeric strings like "40.7abc" instead of
requiring valid numeric input. Replace the parseFloat calls for latitude and
longitude with Number() instead, and update the validation checks from isNaN()
to Number.isFinite() to ensure the entire input string is numeric and not just a
numeric prefix. This will reject invalid coordinate strings while accepting
valid numeric values.

In `@packages/visual-editor/src/components/locator/LocatorWrapper.tsx`:
- Line 114: The call to `setSessionTrackingEnabled(true)` on the searcher object
is being executed synchronously during the render phase of the LocatorWrapper
component, which is a side effect that should not occur during render. Move this
call into a useEffect hook with an appropriate dependency array (likely
depending on the searcher instance) to ensure the side effect only runs after
the component mounts and when the searcher is initialized, not during the render
phase itself.

---

Nitpick comments:
In `@packages/visual-editor/src/components/locator/LocatorWrapper.tsx`:
- Around line 204-211: The handleDrag function is used as a dependency in
mapProps but is not memoized, causing mapProps to recalculate on every render.
Wrap the handleDrag function definition with useCallback hook and include its
dependencies (setMapCenter, setMapRadius, setShowSearchAreaButton) in the
useCallback dependency array. This will ensure that handleDrag maintains
referential equality across renders unless its dependencies change, preventing
unnecessary recalculations of mapProps that includes handleDrag in its
definition around lines 483-500.
🪄 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

Run ID: 80d55124-dea4-44c0-ae90-eaa9eb187c9d

📥 Commits

Reviewing files that changed from the base of the PR and between 196f5e1 and 32bfe80.

📒 Files selected for processing (11)
  • packages/visual-editor/src/components/Locator.tsx
  • packages/visual-editor/src/components/categories/LocatorCategory.tsx
  • packages/visual-editor/src/components/index.ts
  • packages/visual-editor/src/components/locator/Locator.test.tsx
  • packages/visual-editor/src/components/locator/Locator.tsx
  • packages/visual-editor/src/components/locator/LocatorFilters.tsx
  • packages/visual-editor/src/components/locator/LocatorMap.tsx
  • packages/visual-editor/src/components/locator/LocatorResultCard.tsx
  • packages/visual-editor/src/components/locator/LocatorResults.tsx
  • packages/visual-editor/src/components/locator/LocatorWrapper.tsx
  • packages/visual-editor/src/components/locator/locatorUtils.ts
💤 Files with no reviewable changes (1)
  • packages/visual-editor/src/components/Locator.tsx

Comment thread packages/visual-editor/src/components/locator/locatorUtils.ts
Comment thread packages/visual-editor/src/components/locator/LocatorWrapper.tsx
"tertiaryHeading",
] as const;

const ResultCardPropsField = ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason this is in Locator and not LocatorResults?

} from "../../utils/themeConfigOptions.ts";
import { LocatorConfig } from "../../utils/types/StreamDocument.ts";

export const RESULTS_LIMIT = 20;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some of these seem like they'd be better in Locator.tsx > locatorUtils.ts ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-dev-release Triggers dev release workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants