refactor: add 'optionalNumber' a fieldType#1174
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughRefactors 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
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
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
🤖 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
📒 Files selected for processing (9)
packages/visual-editor/src/editor/OptionalNumberField.tsxpackages/visual-editor/src/editor/README.mdpackages/visual-editor/src/editor/YextField.test.tsxpackages/visual-editor/src/editor/YextField.tsxpackages/visual-editor/src/editor/index.tspackages/visual-editor/src/fields/OptionalNumberField.test.tsxpackages/visual-editor/src/fields/OptionalNumberField.tsxpackages/visual-editor/src/fields/fields.tspackages/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
auto-screenshot-update: true
No description provided.