Skip to content

refactor: remove video from YextField#1186

Merged
asanehisa merged 5 commits intomainfrom
video-field
Apr 29, 2026
Merged

refactor: remove video from YextField#1186
asanehisa merged 5 commits intomainfrom
video-field

Conversation

@asanehisa
Copy link
Copy Markdown
Contributor

@asanehisa asanehisa commented Apr 28, 2026

Confirmed Video works in fake starter

@asanehisa asanehisa added the create-dev-release Triggers dev release workflow label Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

Walkthrough

The PR moves video handling out of the centralized YextField factory and the removed constant-value-fields Video component into a new dedicated VideoField module with a VideoFieldOverride UI. It updates the fields registry to include the new video field and adjusts content block schema usage to define the assetVideo field inline. The new override coordinates video selection via parent drawer messages with a pending-session id and provides a fake-local-dev URL prompt fallback.

Sequence Diagram(s)

sequenceDiagram
  participant Field as VideoFieldOverride
  participant Parent as Parent Drawer
  participant Store as Editor State
  Field->>Parent: send constantValueEditorOpened(messageId)
  Parent-->>Field: open drawer, user selects AssetVideo
  Parent->>Field: constantValueEditorClosed(messageId, selectedAsset)
  alt messageId matches session
    Field->>Store: onChange(selectedAsset)
  else mismatch
    Field-->>Store: ignore
  end
  Note right of Field: In fake local-dev, "Change" prompts for URL and Field->>Store: onChange(parsed AssetVideo)
Loading

Possibly related PRs

Suggested reviewers

  • mkilpatrick
  • benlife5
  • jwartofsky-yext
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided; the pull request lacks context about the refactoring rationale, migration strategy, or impact assessment. Add a description explaining the refactoring rationale, how video fields are now handled via the new VideoField component, and any breaking changes for users.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring work: removing video field support from YextField and relocating it to a dedicated VideoField implementation.
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 video-field

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.

@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
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 28, 2026

commit: c514ee1

github-actions Bot and others added 2 commits April 28, 2026 19:29
Copy link
Copy Markdown
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: 2

🧹 Nitpick comments (1)
packages/visual-editor/src/fields/VideoField.test.tsx (1)

47-71: Cover the new message-driven selection flow too.

This suite only exercises rendering and delete. The new behavior in packages/visual-editor/src/fields/VideoField.tsx is the pending-session/message roundtrip, so one matching/non-matching constantValueEditorClosed test would catch the regressions most likely to break selection.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/src/fields/VideoField.test.tsx` around lines 47 - 71,
Add tests to VideoField.test.tsx to exercise the new message-driven selection
flow: after rendering via renderField (with and without assetVideo), simulate
the pending-session/message roundtrip by dispatching the
constantValueEditorClosed message event used by VideoField.tsx (send both a
matching session id payload to assert onChange is called with the selected asset
and a non-matching session id payload to assert no change), and assert the
component reacts correctly (onChange invoked with the expected value for
matching session, not invoked for non-matching). Use the existing renderField
and assetVideo fixtures and wire the same session id that the component
registers so the test mirrors the real message flow.
🤖 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/src/fields/VideoField.tsx`:
- Around line 59-79: Wrap the local-dev prompt parsing in a safe validation
block: when isFakeStarterLocalDev() is true, capture the prompt result and guard
the URL construction and search param extraction (the new URL(userInput) and
searchParams.get("v")) inside a try/catch and verify that videoId and userInput
are non-empty and valid before calling onChange with the mock AssetVideo object;
if parsing fails or videoId is falsy, simply return without calling onChange to
leave the selection unchanged.
- Around line 136-153: Update the overlay container div in VideoField.tsx (the
div that wraps the Change/Delete Buttons) to include a focus-based visibility
class so keyboard users can see the actions; add focus-within:ve-opacity-100 to
the existing className on that div so focusing either Button (handleSelectVideo
or handleDeleteVideo) will make the overlay visible. Ensure the buttons remain
focusable (no extra change needed unless they've been disabled) so tabbing into
handleSelectVideo/handleDeleteVideo triggers the focus-within rule.

---

Nitpick comments:
In `@packages/visual-editor/src/fields/VideoField.test.tsx`:
- Around line 47-71: Add tests to VideoField.test.tsx to exercise the new
message-driven selection flow: after rendering via renderField (with and without
assetVideo), simulate the pending-session/message roundtrip by dispatching the
constantValueEditorClosed message event used by VideoField.tsx (send both a
matching session id payload to assert onChange is called with the selected asset
and a non-matching session id payload to assert no change), and assert the
component reacts correctly (onChange invoked with the expected value for
matching session, not invoked for non-matching). Use the existing renderField
and assetVideo fixtures and wire the same session id that the component
registers so the test mirrors the real message flow.
🪄 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: c1d53f12-dd6e-4762-a926-eb832063a478

📥 Commits

Reviewing files that changed from the base of the PR and between 67fd06c and ee38061.

⛔ Files ignored due to path filters (2)
  • packages/visual-editor/src/components/testing/screenshots/Locator/[desktop] latest version multi-pageset default props.png is 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.png is excluded by !**/*.png, !packages/visual-editor/src/components/testing/screenshots/**
📒 Files selected for processing (8)
  • packages/visual-editor/src/components/contentBlocks/Video.tsx
  • packages/visual-editor/src/editor/YextField.test.tsx
  • packages/visual-editor/src/editor/YextField.tsx
  • packages/visual-editor/src/fields/VideoField.test.tsx
  • packages/visual-editor/src/fields/VideoField.tsx
  • packages/visual-editor/src/fields/fields.ts
  • packages/visual-editor/src/fields/index.ts
  • packages/visual-editor/src/internal/puck/constant-value-fields/Video.tsx
💤 Files with no reviewable changes (2)
  • packages/visual-editor/src/editor/YextField.test.tsx
  • packages/visual-editor/src/internal/puck/constant-value-fields/Video.tsx

Comment thread packages/visual-editor/src/fields/VideoField.tsx
Comment thread packages/visual-editor/src/fields/VideoField.tsx Outdated
Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
packages/visual-editor/src/fields/VideoField.tsx (1)

59-67: ⚠️ Potential issue | 🟡 Minor

Guard local-dev URL parsing before constructing the mock asset.

Line 64 can throw on malformed input, and Line 66 can yield an empty videoId, producing invalid thumbnail/embed URLs. Bail out on parse failure or missing v before onChange.

Suggested fix
     if (isFakeStarterLocalDev()) {
       const userInput = prompt("Enter Video URL:");
       if (!userInput) {
         return;
       }
-      const url = new URL(userInput);
-      const searchParams = new URLSearchParams(url.search);
-      const videoId = searchParams.get("v") ?? "";
+      let url: URL;
+      try {
+        url = new URL(userInput);
+      } catch {
+        return;
+      }
+      const videoId = url.searchParams.get("v");
+      if (!videoId) {
+        return;
+      }

       onChange({
         name: "Local asset",
         id: "0",
#!/bin/bash
# Verify whether local-dev URL parsing is guarded in VideoField.
rg -n -C3 'isFakeStarterLocalDev\(\)|new URL\(|try\s*\{|searchParams\.get\("v"\)|url\.searchParams\.get\("v"\)' packages/visual-editor/src/fields/VideoField.tsx
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/visual-editor/src/fields/VideoField.tsx` around lines 59 - 67, Guard
the local-dev URL parsing in VideoField: wrap the new URL(userInput) /
URLSearchParams parsing in a try-catch around the block executed when
isFakeStarterLocalDev() is true, and validate that the extracted videoId (from
searchParams.get("v")) is non-empty before constructing the mock asset and
calling onChange; if parsing fails or videoId is empty, bail out (return)
instead of proceeding to create thumbnail/embed URLs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/visual-editor/src/fields/VideoField.tsx`:
- Around line 59-67: Guard the local-dev URL parsing in VideoField: wrap the new
URL(userInput) / URLSearchParams parsing in a try-catch around the block
executed when isFakeStarterLocalDev() is true, and validate that the extracted
videoId (from searchParams.get("v")) is non-empty before constructing the mock
asset and calling onChange; if parsing fails or videoId is empty, bail out
(return) instead of proceeding to create thumbnail/embed URLs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8aa12248-2bbd-45e3-9963-befd276d09ad

📥 Commits

Reviewing files that changed from the base of the PR and between ee38061 and c514ee1.

📒 Files selected for processing (1)
  • packages/visual-editor/src/fields/VideoField.tsx

@asanehisa asanehisa marked this pull request as ready for review April 28, 2026 21:09
@asanehisa asanehisa merged commit 4ffb140 into main Apr 29, 2026
19 checks passed
@asanehisa asanehisa deleted the video-field branch April 29, 2026 13:02
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.

3 participants