Added Edit button to the DataForm panel layout #73036
Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @poligilad-auto. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jimjasson! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Screen.Recording.2025-11-13.at.16.37.49.mov
Screen.Recording.2025-11-13.at.16.52.04.mov
This is how QuickEdit behaves in Site Editor > Pages (need to have enabled the experiment in Gutenberg > Experiments). Note how the template field renders its own dropdown with one or two actions before opening the modal. We don't support that level of interaction right now, so the field built its own custom Edit component. Screen.Recording.2025-11-13.at.17.06.11.mov |
I don't know if we can align on this for all DataForm fields (maybe not the panel view), but we prefer the label to be the same styling as input fields (bold) but with gray color instead of black to indicate that this is read-only.
Editable read-only fields will have bolder text, similar visually to buttons. It's a little subtle, but it was the latest approach.
We also suggested a background color on hover to emphasize the editable fields.
Maybe we can solve this with copy, like this. "Enter value" for example, with gray text to indicate that it's empty.
@jameskoster any other thoughts? |
|
In terms of the general UX a dedicated edit button makes sense and seems like a nice a11y enhancement, but I think the entire field should also be clickable to trigger the modal/popover. Additionally the pencil button should appear when hovering the whole field to address Andrés first feedback. I made a prototype here to demonstrate the interaction. Otherwise @poligilad-auto's feedback sounds good. I could potentially see un-editable field values being gray too to further distinguish, but it's not a strong feeling. Here's a diagram to illustrate in case it's useful:
Is this definitely something we want to support moving forwards? Actions potentially feel a bit out of scope for DataForm and things can get a bit complex when actions are conditionally available (IE what do we do after the template has been reset, show a menu containing one item?). In this particular example swapping the template seems fine, but the 'reset' action should arguably live elsewhere, grouped with other contextual actions like "Rename", "Trash", and so on. If we do want to support this then maybe we replace the pencil icon with a more icon and show it when hovering the field. But in this case only the icon button would be interactive, not the entire field.
|
I also agree that actions in DataForm are out of scope for now, so this means that:
@jimjasson this means we need to update how the template field works in Site Editor > Pages. It may be worth addressing this as a separate PR, as preparation for this one. |
|
Thank you for the feedback @poligilad-auto and @jameskoster ! A couple of clarification questions on the designs you proposed, and especially this one:
|
|
Thanks @jimjasson!
You mean "Uneditable" fields, correct? No, it's shouldn't be highlighted.
At the end of the label, like here.
Yes to both, makes sense to align this behavior with DataViews. Jay is AFK this week, but I think he'll agree with with me 🙂 |
|
Regarding empty buttons:
I think that it should be up to each field to decide how it wants to handle its empty state and DataForm shouldn't provide a default one. For example, for some fields it might be more appropriate to have a What do you think @oandregal ? Any chance that the issue with the empty value in the Storybook can be fixed by adding a render function to the Title field? What led me to that thought is that the render function is being called for each field: https://github.com/WordPress/gutenberg/blob/a4de953b608164a20889b3a5090b049b967988e0/packages/dataviews/src/dataform-layouts/panel/summary-button.tsx#L81C7-L81C26. This makes sense because, for example, for boolean fields, the label of each option should be rendered and not the value (which will be true/false). If a render function is required to handle this situation, then perhaps a render function should also handle empty values. |
- Enabled clicking entire field row to trigger edit action - Revelaed edit button on row hover (previously only on value hover) - Increased field value font-weight to 500 for better hierarchy - Styled read-only fields with muted gray-700 color - Implemented smart click detection to avoid triggering on interactive elements - Added `is-read-only` class to read only fields - Improved accessibility for read-only buttons
|
Thanks @poligilad-auto!
What happens in the case where the label is hidden? |
|
Converting to draft, as this is not ready for review yet. |
Oh, that's a hard one. Can we position it at the end of the row in that case? 😅 |
@oandregal Here it is: #73880 |
|
@jameskoster sharing my feedback here as well 🙂 Visually greying out fields introduces hierarchy issues and risks making elements appear disabled. You explored several approaches, and associating a small pencil icon with editable fields still feels like the strongest option to me. Did we discard that direction for any particular reason? |
|
@verofasulo do you mean something like this?
I think the main feedback I received about this approach is that in 99% of cases "it's going to be a lot of pencils" 😅 I think that's valid given most forms won't have many non-editable fields. We should optimise for the more common use cases.
I mentioned this elsewhere, but non-editable fields basically are disabled if we think about the form context. I think the hierarchy point can potentially be addressed by grouping the fields based on whether they're editable or not. Obviously this is a consumer/implementation point though. |
|
The placement of the icons in that one won't work because fields don't always have labels. We might be able to try the previous mockup with a smaller pencil icon, but it's still a lot of pencils 🙈 |
|
@jameskoster @verofasulo @poligilad-auto what are the next steps on this one? The issue with empty values has been mitigated with some improvements, though it's still far from being good enough: Screen.Recording.2026-01-09.at.09.45.01.movFrom what we have now, these are the design changes I see discussed:
Can we ship 1 (making the entire field clickable) as a first step? That's a good improvement that appears to have agreement. In the meanwhile, design can iterate on the second point. |
|
Let's unstick this. I'll support what André suggested:
It addresses the immediate point, and does not preclude future iteration on edit affordances. Jay has explained sufficiently why applying it everywhere will make the editor as it exists today worse. There are valid contexts for DataForm to have separate edit affordances, but that needs iteration that considers these details across the range of DataForm contexts. |
|
I'd tend to agree that can be the iteration and endstate. The challenge is that this is one component, so it needs a systematic approach to what makes the edit icon show up: is it based on density? Is it based on a mix of componentry? And that needs to then be codified, which is the only part that's tricky. That's why I'd recommend shipping this as TWO PRs. One that addresses the urgent need as proposed, and one followup as you propose. |
|
We should probably continue this discussion in a separate issue, but it may be worth exploring an approach that only distinguishes between editable and non-editable fields when they coexist within the same form. That would allow examples like the Inspector to remain pencil-less. |
|
I'm preparing a separate PR to address the first step as outlined here at #75290 It makes the whole field clickable. The second step (different edit modes) will be a follow-up PR to be prepared when that lands. |
|
#75290 has landed. |















What?
This PR improves the edit interaction for DataForm panel fields by replacing the clickable field value with a separate edit button that appears on hover.
Why?
The previous implementation made entire field values look and behave like buttons. This created an accessibility issue where screen readers would only announce "Edit [field name]" without revealing the current field value, leaving users without crucial context.
How?
SummaryButtonto render a wrapper div containing the summary content and a separate icon button, replacing the previous single-button implementation..dataforms-layouts-panel__summary-wrapperwith hover states that fade the edit button in/out, plus@media (hover: none)to keep buttons always visible on touch devices.useInstanceIdto generate unique IDs for summary content, then linked each edit button to its summary usingaria-describedbyso screen readers announce both the action and current value.Questions
readOnlyfields, I decided to not show the Edit button. Do you agree with this decision?labelPositionprop ofSummaryButtonwas previously used to determine thevariantof the button that overlayed the field value. I don't think that this is needed any longer. Do you agree?Testing Instructions
npm run storybook:dev.DataFormexamples.panelfields are no longer clickable -- instead an edit button appears on hover.Testing Instructions for Keyboard
npm run storybook:dev.DataFormexamples.panelfield, e.g theCustomercard.tabkey to navigate the page.enterthe edit panel opens up.Screen.Capture.on.2025-11-06.at.10-22-30.mp4
Screenshots or screencast
Desktop experience
Screen.Capture.on.2025-11-06.at.10-30-00.mp4
Mobile experience
Screen.Capture.on.2025-11-06.at.10-31-20.mp4