-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
While working on #74147, @talldan noticed that if you toggle the Title field while the Media field is visible, then it jumps from its controlled position within the list, which looks a bit awkward, but also results in a focus loss when interacting via keyboard. I believe the cause is that we only lock the position of the fields when they're visible, but not when they're hidden:
gutenberg/packages/dataviews/src/components/dataviews-view-config/properties-section.tsx
Lines 69 to 95 in 804e44b
| const lockedFields = [ | |
| { | |
| field: titleField, | |
| isVisibleFlag: 'showTitle', | |
| }, | |
| { | |
| field: previewField, | |
| isVisibleFlag: 'showMedia', | |
| }, | |
| { | |
| field: descriptionField, | |
| isVisibleFlag: 'showDescription', | |
| }, | |
| ].filter( ( { field } ) => isDefined( field ) ); | |
| const visibleFieldIds = view.fields ?? []; | |
| const visibleRegularFieldsCount = regularFields.filter( ( f ) => | |
| visibleFieldIds.includes( f.id ) | |
| ).length; | |
| let visibleLockedFields = lockedFields.filter( | |
| ( { field, isVisibleFlag } ) => | |
| // @ts-expect-error | |
| isDefined( field ) && ( view[ isVisibleFlag ] ?? true ) | |
| ) as Array< { | |
| field: NormalizedField< any >; | |
| isVisibleFlag: string; | |
| } >; |
I can see the reasoning as it looks good when the locked visible fields are all at the top together. On balance, though, I think if we're forcing this order, then it might be better to retain that order irrespective of the status of the isVisibleFlag.
Also, previously the locked fields that didn't allow enableHiding had a lock icon, which is no longer present. I think that was an intentional removal by @youknowriad to simplify things, but I may be misremembering. Just mentioning it here in case it wasn't intentional.
Step-by-step reproduction instructions
To see it in practice, you can test with the media modal experiment:
With this enabled, go to add a featured image to a post, then switch to the table view. Play around with toggling field visibility for the title field.
Screenshots, screen recording, code snippet
2025-12-22.12.10.54.mp4
Environment info
No response
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure