DataViews: Do not render an item for visible locked items in properties config menu
What
Stop rendering FieldItem components for visible locked fields in the properties section of the DataViews view config.
Why
Visible locked fields are always visible and cannot be toggled off when they're already shown. Displaying them in the properties list adds unnecessary UI clutter and can confuse users since these items appear interactive but don't provide meaningful actions when visible.
How
Removed the visibleLockedFields.map() block that was rendering FieldItem components for visible locked fields. The visibleLockedFields variable is still calculated and used for logic (determining total visible fields count and preventing hiding when only one field is visible), but these items are no longer rendered in the UI. Hidden locked fields and regular fields continue to render as before.
| Pages DataView Before | Pages DataView After |
|---|---|
Note there is no longer a 'Title' item in the menu because the Title field cannot be toggled on/off.
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 props-bot label.
If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: oandregal <[email protected]>
Co-authored-by: fcoveram <[email protected]>
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.
An alternative approach here would be to keep the menu item visible, but make it disabled, or show a lock icon.
I decided to try hiding it altogether inspired by MacOS Finder which also hides untoggle-able items.
Seems reasonable to me.
Flaky tests detected in aaee5000d820a3e621183d922075ecf51e6961e7. Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20101047876 📝 Reported issues:
- #73752 in
/test/e2e/specs/site-editor/template-id-format.spec.js
This changes a few things:
- title, media, description cannot be hidden, if present
- it's not clear why sometimes you can hide the "last field", and sometimes you cannot
This is how it works in trunk (displays all fields visible, but cannot hide the last visible field):
https://github.com/user-attachments/assets/2f1b5157-7229-4a2a-9e91-bf910640837c
This is how it works with this change (can hide any fields because there's title/media/description):
https://github.com/user-attachments/assets/dc2d65dc-1d2d-40c4-9228-2b598816be31
However, this is what happens when there is no title/media/description is provided (cannot hide the last field):
https://github.com/user-attachments/assets/a9f0b528-9c79-4a9e-a096-3c1581178a8e
@oandregal Good catch. Do you think it would make sense to simply disable the last visible field (when there's no title/media/description)? Is that possible?
Showing it active and disabled makes sense to me.