Skip to content

refactor: add 'optionalNumber' a fieldType#1174

Merged
mkilpatrick merged 5 commits intomainfrom
number
Apr 24, 2026
Merged

refactor: add 'optionalNumber' a fieldType#1174
mkilpatrick merged 5 commits intomainfrom
number

Conversation

@mkilpatrick
Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d74c25c7-f3ff-4cfb-96f1-b6af8aa7cc61

📥 Commits

Reviewing files that changed from the base of the PR and between b574786 and f38c42b.

⛔ Files ignored due to path filters (3)
  • 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/**
  • packages/visual-editor/src/components/testing/screenshots/PhotoGallerySection/[desktop] version 59 with showSectionHeading false.png is excluded by !**/*.png, !packages/visual-editor/src/components/testing/screenshots/**
📒 Files selected for processing (1)
  • packages/visual-editor/src/editor/YextField.test.tsx
💤 Files with no reviewable changes (1)
  • packages/visual-editor/src/editor/YextField.test.tsx

Walkthrough

Refactors OptionalNumberField from an editor-level React component into a registered puck-style field override. Deleted the editor/component and its editor exports/tests; added a new field type and override under src/fields, registered the override in fields.ts and re-exported it from fields/index.ts, added end-to-end field tests, updated YextField to stop delegating to the removed editor component and tightened the puck-field fallback, updated the editor README to the registered-field config shape, and added new locale keys for field labels across multiple locale files.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer UI
  participant YextField
  participant OptionalNumberFieldOverride as OptionalNumberFieldOverride
  participant AutoField
  participant Store as Data Store

  Dev->>YextField: render field config (type: "optionalNumber")
  YextField->>OptionalNumberFieldOverride: instantiate override with field config
  OptionalNumberFieldOverride->>AutoField: render radio AutoField ("hide"/"show")
  OptionalNumberFieldOverride->>AutoField: render number AutoField when shown
  AutoField->>Store: onChange -> update value
  Store-->>Dev: updated value reflected in UI
Loading
sequenceDiagram
  participant Dev as Developer UI
  participant YextField
  participant OptionalNumberFieldEditor as OptionalNumberField (removed)
  participant OptionalNumberFieldOverride as Fields Override

  Note over Dev,YextField: Old flow (prior to this PR)
  Dev->>YextField: render field config (type: "optionalNumber")
  YextField->>OptionalNumberFieldEditor: delegate to editor-level component
  OptionalNumberFieldEditor->>Dev: render UI controls

  Note over Dev,YextField: New flow (after this PR)
  Dev->>YextField: render field config (type: "optionalNumber")
  YextField->>OptionalNumberFieldOverride: instantiate fields override
  OptionalNumberFieldOverride->>Dev: render UI controls via AutoField
Loading

Possibly related PRs

  • refactor: code fieldType #1151 — Performs the same refactor pattern: moves an editor-level custom field into src/fields as a puck-style field override and updates YextField and exports accordingly.

Suggested labels

create-dev-release

Suggested reviewers

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

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether any description relates to the changeset. Please add a pull request description explaining the purpose and scope of adding the 'optionalNumber' field type.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring to add 'optionalNumber' as a new field type, which is supported throughout the changeset.
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 number

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.

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: 3

🤖 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/editor/README.md`:
- Line 248: The markdown link fragments for the intra-page anchors are invalid;
update the references in the YextField description so the two links use valid
same-page anchors that match the headings for those sections (e.g., change
"(##YextEntityFieldSelector)" and "(##TranslatableStringField)" to
"(`#YextEntityFieldSelector`)" and "(`#TranslatableStringField`)" or the exact
heading slugs used by the README); ensure the link text still references
YextEntityFieldSelector and TranslatableStringField so the YextField paragraph
correctly navigates to those sections.
- Around line 220-226: Update the props table to reflect that the label prop is
optional: change the "label" row (currently listed as `label` and type `string |
MsgString`) to mark it optional (e.g., add "(optional)" to the Description or
indicate optional in the Type) so the docs match the implementation/tests that
allow omitting label; ensure the other related rows (hideNumberFieldRadioLabel,
showNumberFieldRadioLabel, defaultCustomValue) remain unchanged.

In `@packages/visual-editor/src/fields/OptionalNumberField.tsx`:
- Around line 32-58: The hidden state should not be determined by comparing the
persisted value to the current hide label string; change the isHidden check to
treat anything other than SHOW_OPTION_VALUE as hidden (e.g., const isHidden =
value !== SHOW_OPTION_VALUE) so persisted custom hidden strings still render the
radio as "hidden" and the number input stays empty; keep the AutoField onChange
logic (which writes either field.hideNumberFieldRadioLabel or
field.defaultCustomValue) and the radio's value mapping (value={isHidden ?
field.hideNumberFieldRadioLabel : SHOW_OPTION_VALUE}), and add a regression test
that loads a persisted non-SHOW_OPTION_VALUE string and asserts the field
renders as hidden.
🪄 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: 552ff70d-37f5-4627-ad3f-7fd78c9a99f0

📥 Commits

Reviewing files that changed from the base of the PR and between 7359227 and ce31b7f.

📒 Files selected for processing (9)
  • packages/visual-editor/src/editor/OptionalNumberField.tsx
  • packages/visual-editor/src/editor/README.md
  • packages/visual-editor/src/editor/YextField.test.tsx
  • packages/visual-editor/src/editor/YextField.tsx
  • packages/visual-editor/src/editor/index.ts
  • packages/visual-editor/src/fields/OptionalNumberField.test.tsx
  • packages/visual-editor/src/fields/OptionalNumberField.tsx
  • packages/visual-editor/src/fields/fields.ts
  • packages/visual-editor/src/fields/index.ts
💤 Files with no reviewable changes (2)
  • packages/visual-editor/src/editor/index.ts
  • packages/visual-editor/src/editor/OptionalNumberField.tsx

Comment thread packages/visual-editor/src/editor/README.md
Comment thread packages/visual-editor/src/editor/README.md
Comment thread packages/visual-editor/src/fields/OptionalNumberField.tsx Outdated
Comment thread packages/visual-editor/src/fields/OptionalNumberField.tsx
@mkilpatrick mkilpatrick merged commit cba3515 into main Apr 24, 2026
17 checks passed
@mkilpatrick mkilpatrick deleted the number branch April 24, 2026 14:01
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.

4 participants