-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: make mediaField
not hidable
#56643
Conversation
f5ee1d6
to
c5278a9
Compare
Size Change: +10 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
mediaField
not hidable
If the field is hidden in the "table" layout and you switch to "grid" layout, it will stay "hidden" in the view object even if it's not visible in the UI. That's probably fine, but thought I'd mention. |
That's actually a good thing that I've demoed in the PR description. Consider the following case:
What'd you expect the visibility status of the featured image to be? I'd like the featured view to be one of the visible columns (this is: "remembers" my choice). Gravacao.do.ecra.2023-11-29.as.15.02.19.mov |
Flaky tests detected in c5278a9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7033528927
|
Though, you were perhaps thinking about this use case:
Some days go on, and then the user comes back to this page:
At this point, the feature image column would be shown in the table. What do you feel about this? I'm fine with it. |
@@ -139,7 +139,8 @@ function PageSizeMenu( { view, onChangeView } ) { | |||
|
|||
function FieldsVisibilityMenu( { view, onChangeView, fields } ) { | |||
const hidableFields = fields.filter( | |||
( field ) => field.enableHiding !== false | |||
( field ) => | |||
field.enableHiding !== false && field.id !== view.layout.mediaField |
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 a follow-up PR, I'd like to investigate what if we removed enableHiding
from our API and favor the following logic: all fields are visible unless they are the view.layout.primaryField
or view.layout.mediaField
.
The primaryField
config is only working on the grid
layout type, but there is no reason it cannot be expanded to all layouts. For example, the side-by-side
could use it to determine which field that triggers the "side by side" view (in addition to prevent hiding 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.
all fields are visible unless they are the view.layout.primaryField or view.layout.mediaField.
I assume you mean all fields are hideable, right? If yes in the future we could have more fields that we don't want to be hideable, but still not the primary one. For example in a product title(primary), price not hideable.
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.
That's good, I'll leave it as it is.
Upon sleeping on it, I think what I don't like about the existing enableHiding
is that is a view-concern that lives in the Field API. The same as maxWidth
, etc. That may be fine when you only have a single view (TanStack table), but it's not necessarily good when you may have some – each may need different view tweaks.
Ok, so this PR is ready then :)
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.
For me, this is good enough.
Part of #55083
What
This PR makes the
mediaField
not hidable.Gravacao.do.ecra.2023-11-29.as.15.02.19.mov
Why
Right now, on
trunk
, the media field is displayed on the field visibility, even though it cannot be hidden.How
Take into account the
view.layout.mediaField
into the logic for listing hidable fields.Testing