Skip to content

feat: image url support for image fields in local editor#1242

Open
briantstephan wants to merge 1 commit into
2026-custom-components-templatesfrom
local-editor-images
Open

feat: image url support for image fields in local editor#1242
briantstephan wants to merge 1 commit into
2026-custom-components-templatesfrom
local-editor-images

Conversation

@briantstephan

Copy link
Copy Markdown
Contributor

This allows users of the local-editor to update image fields using a publicly-hosted image URL, like in the fake starter.

Demo:

Screen.Recording.2026-06-18.at.4.17.22.PM.mov

@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.

return getPathname(locationLike).startsWith("/dev-");
};

export const isLocalEditorRoute = (locationLike: LocationLike) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we just update isFakeStarterLocalDev? If we want both, I'd make it a callable func without having to pass in variables like we do for isFakeStarterLocalDev. It's weird that that one handles window undefined and window.location but you make those calls manually in usages for this func.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change adds a new exported helper isLocalEditorRoute(locationLike) to isFakeStarterLocalDev.ts that returns true when the resolved pathname equals "/local-editor". Both ImageField.tsx and EmptyImageState.tsx import this helper and expand their image-selection branch condition so the prompt-based URL entry flow is triggered not only when isFakeStarterLocalDev() is true, but also when the browser is on the local-editor route. Test coverage in isFakeStarterLocalDev.test.ts gains a new describe block for the helper, and ImageField.test.tsx is updated to remove the translatableStringFieldMock hoist, simplify the useTemplateMetadata mock, restore window.location in afterEach, and add a test case for the local-editor prompt path.

Possibly related PRs

  • yext/visual-editor#1102: Modifies the same EmptyImageState.tsx image selection flow, specifically the pending message-id handling used during the prompt-based URL entry path that this PR expands.
  • yext/visual-editor#1184: Introduces the ImageField image-selector behavior that this PR extends with the isLocalEditorRoute branch condition.

Suggested labels

create-dev-release

Suggested reviewers

  • benlife5
  • jwartofsky-yext
  • mkilpatrick
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature being added: image URL support for image fields in the local editor.
Description check ✅ Passed The description clearly relates to the changeset, explaining that the feature allows local-editor users to update image fields using publicly-hosted URLs and provides a demo video.
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 local-editor-images

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: 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/src/fields/ImageField.test.tsx`:
- Around line 74-75: The window.prompt spy is mocked in the prompt-related tests
but not explicitly restored in the shared afterEach cleanup block, causing the
mock to leak into subsequent tests. In the afterEach block (where
window.history.replaceState is called), add an explicit restoration of the
window.prompt spy to ensure the mock is cleaned up after each test and prevent
test order dependencies.
🪄 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: 9294f9cc-f8fe-41e9-8b60-db04af573c99

📥 Commits

Reviewing files that changed from the base of the PR and between 67c7baa and 0cd5f53.

📒 Files selected for processing (5)
  • packages/visual-editor/src/components/contentBlocks/image/EmptyImageState.tsx
  • packages/visual-editor/src/fields/ImageField.test.tsx
  • packages/visual-editor/src/fields/ImageField.tsx
  • packages/visual-editor/src/utils/isFakeStarterLocalDev.test.ts
  • packages/visual-editor/src/utils/isFakeStarterLocalDev.ts

Comment on lines +74 to 75
window.history.replaceState({}, "", initialUrl);
});

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Restore mocked spies in shared cleanup.

window.prompt is mocked in prompt tests but not explicitly restored in shared teardown, which can leak mocked behavior into later tests and create order-dependent failures.

Suggested fix
afterEach(() => {
+  vi.restoreAllMocks();
  sendToParentMock.mockReset();
  window.history.replaceState({}, "", initialUrl);
});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
window.history.replaceState({}, "", initialUrl);
});
afterEach(() => {
vi.restoreAllMocks();
sendToParentMock.mockReset();
window.history.replaceState({}, "", initialUrl);
});
🤖 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/fields/ImageField.test.tsx` around lines 74 - 75,
The window.prompt spy is mocked in the prompt-related tests but not explicitly
restored in the shared afterEach cleanup block, causing the mock to leak into
subsequent tests. In the afterEach block (where window.history.replaceState is
called), add an explicit restoration of the window.prompt spy to ensure the mock
is cleaned up after each test and prevent test order dependencies.

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