-
Notifications
You must be signed in to change notification settings - Fork 4.7k
DataForm: Fix panel field inaccessible when empty with labelPosition none #73764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataForm: Fix panel field inaccessible when empty with labelPosition none #73764
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 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. |
|
cc: @oandregal, @jameskoster |
| 'aria-expanded'?: boolean; | ||
| } ) { | ||
| const isEmpty = | ||
| labelPosition === 'none' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still familiarizing myself with DF, but I think:
- the same problem occurs even with a label
- the same problem occurs at least in
cardlayout
When empty should we use for summaryContent an edit: ${attribute label} instead of empty field? I think that's better, but if we went for an empty field approach, it should be different based on the number of fields.
Finally with this change in the story ?path=/story/dataviews-dataform--layout-panel&args=labelPosition:none the discussion appears empty. Is this in indicator that we need a getValue there in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edit: ${attribute label}
I had a similar thought 👍
Edit: I realised this is a bit related to #73036. "${attribute label} unset" could also be an option for when the label is hidden. When the label is visible we might not need to repeat it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned here: #73036 (comment), 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 -, for others a placeholder text etc. This can be controlled via the field's render function.
So perhaps the solution here is to update the Storybook example and add a render function to fields that can have an empty value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there still be a fallback in case a field doesn't supply an empty state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a curated fallback, other than the one we have now, which is displaying an empty space ''?
Looking at the current proposal, it doesn't seem like the field's render function is taken into account. Instead, if the value is empty, then __( '(Empty field)' ) is rendered. The render function is only used when else if ( summaryFields.length > 1 ).
I understand the UX benefits of having a curated fallback, but as a developer I would expect to have control over the empty state of a field via render, without having to change its value (i.e. what is returned via getValue). For example, the value of a field could be '', but I might want to display it as -.
I think that we must keep the consistency of displaying the field's value as is, unless a render function is provided. If the value is '', display it as ''. If the value is abc, display it as abc. Having a special render function that runs only when the field has a specific value (empty is this case) and the field doesn't provide a render function, doesn't seem very consistent and intuitive in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a curated fallback, other than the one we have now, which is displaying an empty space ''?
Yeah. I suppose the problem I'm conscious about is when labelPosition is none and the value is '' you basically get an empty row in the UI which looks broken.
I agree the consumer should have some level of control over the empty state render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ntsekouras, @jameskoster I update to use "${attribute label} unset" when label position is none and "${attribute label}" when label is shown (we repeat the label).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jimjasson, you raised a very good point, we should allow consumers to have their own empty states using the render function. I totally change the implementation to be based on css :empty pseudo selector, only if the element is in fact empty and the render function did not provided any output we use the fallback, so consumers of the API now have full control if they want a different fallback.
8e0c8ad to
7bf23cf
Compare
|
Hi @jameskoster, @jimjasson, @ntsekouras this is ready for a new look. |
|
Size Change: +172 B (+0.01%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in b05b11f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20307061017
|
…lds when label position is none.
910e0f5 to
da9e9b1
Compare
|
I rebased and added the changelog entry, the CI should now be green. |
|
I tried this and this is how it looks like: Screen.Recording.2025-12-18.at.12.03.41.movIf we introduce an empty state, it should be obviously different from the actual content (now it isn't) and it should be the same regardless of panel layout state (label position, dropdown/modal, etc.). There's also the ongoing work to introduce a different edit mechanic (edit pencil icon), so I wonder: can we scope this down to just prevent the button's width from collapsing for top/none label states? |
|
Closing in favor of #74264. |
This PR Adds a fallback placeholder for empty panel fields when
labelPositionis set tonone.Why?
When a DataForm panel field has
labelPosition: noneand the field value is empty, the summary button renders with no content, collapsing to zero width. This makes the field inaccessible since there's nothing to click to open the panel. There is no way a use can open the field panel and make the field not empty.How?
Display "(Empty field)" text when
labelPosition === 'none'and all summary field values are empty.Testing
labelPosition: nonehttp://localhost:50240/?path=/story/dataviews-dataform--layout-panel&args=labelPosition:none