Dashboard: migrate Layout settings drawer to DataForm#78336
Conversation
declarative field schema with synthetic toggles for fixed columns and auto row height; spacing now matches the dashboard's form surfaces
per simison's review on PR #78202: NumberControl with spinControls="custom" for Columns, Min column width, and Row height
|
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. |
|
Size Change: 0 B Total Size: 7.96 MB ℹ️ View Unchanged
|
|
Flaky tests detected in b9da43c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25914743372
|
|
Should we use I still think some of the options are a bit strange. What's the benefit to disabling "Fixed column count"? It just seems to introduce complexity—now I need to choose a specific column width, and I can choose invalid (very large) values. Also changing the column count; do we really need so much granularity there? Seems like a couple of preset options (also using In Masonry layout the "Auto-fit row height to content" and "Row height (px)" fields always seem to be disabled—this feels a bit broken. We should probably just hide them if they never become active. |
Yes. Updating...
I think it does make sense, but we probably need to work in the Grid package to properly combine the column counts with minColumnWidth. I'll merge this PR as it, since the purpose is basically using a Form instance for the settings, but we continue in a follow-up. |


What?
Migrates
routes/dashboard/widget-dashboard/components/layout-settings/layout-settings.tsxaway from a manualStack+ToggleControl+SelectControl+InputControlcomposition to a declarativeDataFormschema. Follow-up from the #78202 review thread (spacing inconsistency between fields; consistency with the rest of the dashboard's form surfaces).Why?
useCallbacksetter and inline conditional rendering, which made the drawer's body harder to scan.DataFormalready handles layout, label position, and field-conditional visibility / disabled state, so the drawer now matches the rest of the dashboard for free.How?
fields+formconstants at module scope):model—selectwith two elements (grid,masonry).fixedColumns— synthetic boolean toggle;setValuereturns an atomic{ columns, minColumnWidth }update so the underlying grid xor is preserved.columns/minColumnWidth— integer fields gated byisVisiblebased onfixedColumns.autoRowHeight— synthetic boolean toggle;setValueflipsrowHeightbetween'auto'and a numeric default.isDisabledin masonry mode.rowHeight— integer field withisVisible(hidden in masonry) andisDisabled(locked whenautoRowHeight).migrateLayoutmoves into a wrappedonChangethat detects amodeldelta in the edits patch and runs the migration before propagating settings.+/-steppers — a localStepperIntegerEditwrapsNumberControlwithspinControls="custom"and is applied to all integer fields, addressing the second item in the original review thread. Thestepis currently hardcoded to1; see the Follow-ups section.Stack,SelectControl,ToggleControl,InputControlimports; six per-fielduseCallbacksetters; theparsePositiveInthelper; theMODEL_ITEMSconst array. The drawer chrome (Header / Content / Footer + Save / Cancel / Reset) is preserved.Testing
Row heightandAuto-fit row heighthide / disable accordingly.Columns(1–12) andMin column width(≥48).Row heightbecomes disabled; toggling back restores the previous numeric value (200 default).Before
After
Follow-ups
EditConfigdoes not currently exposestepfor integer / number fields; the customstep={ 10 }previously used forMin column widthandRow heightis therefore not yet expressible declaratively. Tracked upstream at DataForm: supportstepandspinControlsinEditConfigfor integer / number fields #78335.