CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataViews: Prevent hiding the last visible field #71625
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
DataViews: Prevent hiding the last visible field #71625
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. |
Flaky tests detected in 702b322. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17844419243
|
This seems good to me, and I agree this behaviour should be the default. |
Agree that this looks good. My first reaction was that removing the image made no sense, as the grid layout prioritizes the visual content to compose the layout. However, I can envision use cases where other fields also compose to the layout. That said, I think that adding a reset action at the end of the properties list could help to go back to the default state. I assume this idea involves defining which visible properties those are. |
b5faa96
to
1f50fc9
Compare
Thanks for confirming and for the feedback, folks!
I think that'd be possible, as it'd be a matter of resetting the view back to its default state of visible fields. Let's leave that out of this PR as it's a little beyond the scope of ensuring folks don't get stuck when hiding all fields. After chatting with @oandregal and with the feedback here that we'd like this to be default behaviour, I've removed the flag. I've also updated the logic so that in cases where there are no visible locked fields, we then add smart locking to the last remaining visible field. This is a bit of an edge case as usually there is at least one title, media, or description field, but helps us ensure that no-one ever gets stuck in a state where no field is visible. For testing that case, I've added a diff to the PR description that includes a separate story that doesn't include the title, media, or description fields. Since it is a bit of an edge case, I haven't included that story as part of this PR, but let me know if anyone thinks it should be included. Thanks again for all the discussion here, everyone! |
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.
This works as advertised, thanks for pushing for it!
Dynamic locking is important for screens such as the media library: depending on the kind of content you have, you may want to lock media (images) or title (files).
Though, I still think most views are expected to lock special fields. Even if this mode, users can still run in weird situations like this one for the grid layout:
Screen.Recording.2025-09-18.at.13.29.28.mov
…re are no locked visible fields
1f50fc9
to
702b322
Compare
Thanks for the review!
Good point. I think we're getting there in terms of providing a good / safe default. For these last cases, would it be worth revisiting / dusting off #71231 for handling the case when the media preview is hidden? And to be thorough about it, would we want a similar behaviour for when the description is hidden? |
What?
Closes #71078 — improve support for hiding titles by enabling a kind of smart locking.
This PR ensures that if at least one field is visible.
This behaviour ensures that at least one field is always visible, to prevent a user from getting into a state where no fields are visible.
Why?
As discussed over in #71078 to add guardrails to the UX of showing and hiding fields so that a user doesn't accidentally wind up with no fields visible.
How?
Testing Instructions
npm run storybook:dev
and navigate to the default DataViews story: https://localhost:50240/?path=/story/dataviews-dataviews--defaultThe current stories included with DataViews do not include an example that doesn't set title, media, or description. So, to test that kind of view, you can use the diff below to add an extra story "WithoutLockedFields":
Diff for WithoutLockedFields story
Screenshots or screencast
2025-09-18.14.23.35.mp4