gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

DataViews: Do not render an item for visible locked items in properties config menu

Open jameskoster opened this issue 1 month ago • 5 comments

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
Screenshot 2025-12-10 at 13 40 55 Screenshot 2025-12-10 at 13 44 10

Note there is no longer a 'Title' item in the menu because the Title field cannot be toggled on/off.

jameskoster avatar Dec 10 '25 13:12 jameskoster

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.

github-actions[bot] avatar Dec 10 '25 13:12 github-actions[bot]

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.

jameskoster avatar Dec 10 '25 13:12 jameskoster

Seems reasonable to me.

jasmussen avatar Dec 10 '25 13:12 jasmussen

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

github-actions[bot] avatar Dec 10 '25 14:12 github-actions[bot]

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 avatar Dec 11 '25 18:12 oandregal

@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?

jameskoster avatar Dec 12 '25 13:12 jameskoster

Showing it active and disabled makes sense to me.

fcoveram avatar Dec 12 '25 19:12 fcoveram