DataForm: Add customizable button text to panel modal#76099
DataForm: Add customizable button text to panel modal#76099mikejolley wants to merge 7 commits intotrunkfrom
Conversation
Adds optional applyButtonText and cancelButtonText properties to the PanelLayout configuration type, allowing consumers to customize the modal action button labels. This supports use cases like saving as the modal closes.
- Add type properties to PanelLayout and NormalizedPanelLayout
- Pass button text through normalization (defaults applied in component)
- Extract layout properties in PanelModal and pass to ModalContent
- Use custom text with i18n defaults (__('Apply') and __('Cancel'))
- Add storybook controls for testing both button label variations
- Set default openAs to 'modal' in LayoutPanel story
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use || instead of ?? so empty strings fall back to default labels - Remove unnecessary `as NormalizedPanelLayout` cast since the discriminant check already narrows the type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Size Change: +166 B (0%) Total Size: 6.87 MB
ℹ️ View Unchanged
|
Restructure the panel layout API so modal button labels are scoped
within the openAs configuration rather than being top-level properties.
openAs now accepts either a string ('dropdown' | 'modal') or an object
({ type: 'modal', applyLabel?, cancelLabel? }). Normalization flattens
the object form. Also adds unit tests and conditional storybook controls.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ption Restructure storybook so label controls are scoped to a dedicated 'modalConfig' openAs option. The component assembles the PanelOpenAsModal object from storybook args, keeping getPanelLayoutFromStoryArgs simple. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Flaky tests detected in 8610e40. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22666083505
|
Instead of flattening PanelOpenAsModal into separate applyLabel/cancelLabel properties, keep openAs as 'dropdown' | 'modal' | PanelOpenAsModal on the normalized type. This scopes labels within the modal config consistently across both input and normalized types. Normalization becomes a simple passthrough with ?? 'dropdown' default. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What?
Adds optional
applyLabelandcancelLabelconfiguration to the DataForm panel modal layout'sopenAsconfig, allowing customization of modal action button labels.Why?
Some use cases need different button labels—for example, using "Save" instead of "Apply" when the modal closes after the action. This change enables that flexibility while maintaining backward compatibility with existing code that relies on the default "Apply" and "Cancel" labels.
How?
PanelOpenAsModaltype soopenAsaccepts either a string ('dropdown' | 'modal') or an object ({ type: 'modal', applyLabel?, cancelLabel? })PanelLayoutandNormalizedPanelLayoutuse the sameopenAsunion — normalization is a simple passthrough with?? 'dropdown'default__('Apply')/__('Cancel')) when not providedopenAsis'modalConfig')API example
Testing Instructions
npm run storybook:devmodalConfigwith applyLabel = "Save" and cancelLabel = "Dismiss"modalto verify the default "Apply" and "Cancel" labels appearmodalConfigand clear the label fields to verify defaults reappearTesting Instructions for Keyboard
Screenshots or screencast