-
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: do not display element descriptions in filters #64674
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. |
Size Change: -7 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -284,12 +284,16 @@ function usePostFields( viewType ) { | |||
label: __( 'Status' ), | |||
id: 'status', | |||
type: 'text', | |||
elements: STATUSES, | |||
elements: STATUSES.filter( ( { value } ) => value !== 'trash' ), |
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 it feels weird to kind of duplicate the "elements" property. Also "trash" is a valid value of "status" so I don't think we should be removing it from the "elements" of the field.
Are there any alternatives we can think about than having to duplicate the elements?
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.
There are the requisites, how filtering/editing differ:
- description is a valid option value. In some filters we may actually want to use it if present. In this particular case, we don't and that's different from the edit experience. We cannot just ignore description in the filter.
- the set of valid statuses for filtering and editing is different: in editing we don't want trash.
In most cases, I presume we'd only need field.elements
, so I personally like this approach — it provides some flexibility and it's simple.
Thought a bit about "configuring" elements for the different contexts but I didn't come up with anything I liked more than this.
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.
What you're suggesting is that:
- field.elements is for editing (DataForm) and the default for filters
- field.filterBy.elements is for overriding for filters
- There's nothing to override for "data form".
So the assumption is that "editing" is the main thing for elements. It bothers me a bit that we're treating DataForms and DataViews differently. Also for me, when we define a field, we should ideally detach ourself a bit from how it's used. So I don't really see why "trash" shouldn't be present in field.elements
it's a valid status for that particular field.
One option I suggested before for the "editing" context, is to mark some elements as readonly
.
For the "description" I don't have a good solution either, but I wonder why we want to show the descriptions just for editing and not for filtering. If these are "unclear", they should be clarified in all parts no?
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.
Thought a bit about "configuring" elements for the different contexts but I didn't come up with anything I liked more than this.
What did you try here and you didn't like? For elements
to have an optional context
(edit|view
) prop?
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.
What did you try here and you didn't like? For elements to have an optional context(edit|view) prop?
This, but using a readOnly
prop like Riad had suggested. Limiting the amount of elements to one context or the other is easy.
The crux here is how to "configure descriptions". Edit: the suggestion in the other thread is remove them from the filters, so I'll do that.
Thank you for working on this, the description is definitely overkill in the filter UI. |
Why it's overkill for this field but not other fields? |
Well, it is probably overkill for other existing fields too. Before migrating to data views the Sync filter on the Patterns page was just a segmented control with no descriptions and it worked fine. Perhaps in the future there could be fields that require showing the description in the filter UI is helpful, but there might not, so that feels like a bridge to cross when we arrive at it? |
Yes, this is exactly why I'm asking. The current PR creates a new API that we might not need if we just say "no descriptions in filters" at all. |
That seems like a fine place to start imo. |
Ok, I can update the PR for this. |
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.
LGTM 👍
f1887a9
to
a50e577
Compare
Flaky tests detected in a50e577. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10492192621
|
…64674) Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Follow-up to #64398 (comment)
What?
Remove the description from the field elements.
Why?
The elements in the fields are used for both filters and edit. In the edit form, some fields (status) wants to display descripionts, but this affected filters.
After proposing and discarding an API to have different elements in filters and edit context (see), the way forward for now is not to display descriptions in filters.
How?
Remove the existing display of descriptions in filters. This only affects the "Sync" filter in the Patterns page.
Testing Instructions
Visit the Pages page in the site editor with the "quick edit" form experiment enabled:
trash
and the descriptions are displayed.trash
but with no descriptions.Visit the Patterns page in the site editor and verify that the filter doesn't contain descriptions.