-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataViews: Add data picker functionality #70971
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
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: +2.81 kB (+0.15%) Total Size: 1.93 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 9bca0d4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17452663904
|
|
Nice work @talldan In manual testing selection is working well, and how I'd expect it. Thanks for getting things started. The only question that sprung to mind in relation to the abstraction — bearing in mind I'm still a Dataviews dilettante — what would be an example of its usage in conjunction with Dataviews? Would consumers pick one component or the other or would the I know this was the feedback to create a new component. It just makes me wonder how it all squares with Dataviews' already built-in selection functionality and if we're building "around" an inadequacy. Sorry if I'm way off, just typing things out 😄
My 2c: I think we'd need to first answer whether users expect "Select all" to work across paginations at all. Speaking only for myself, when I see "Select all" on a page, I understand it to mean "select all items currently visible" or, "I know I'm working with what I can see". As far as I can tell this is the standard pattern in apps like Gmail and GitHub 🤷🏻 If the Datapicker allows bulk operations on filtered subsets then that's already a powerful feature, so, unless there's a requirement with sound rationale, I personally don't believe the complexity is worth it. |
+1, also looking at the PR, I do like the idea of an opinionated While testing, I felt like we also need the "cog" icon / sort by drop down that DataViews uses, too? Another challenge with having separate views, is that I imagine if this component is used for something like a post parent picker or a modal for selecting page links, etc, that we'd also really want a Table view for browsing and selecting while viewing more of the fields. So if we have (semi) duplicate Table and Grid views, will that be a challenge for maintenance / ensuring things are always compatible?
Yes, personally I'd expect "Select all" to only refer to the items currently in view, and not span across pagination. |
Rather than having the separate
The way it works right now you can still reuse parts of dataviews - the search, pagination are shared, it's the view and the bulk selection parts that are different. I think this is the part where I don't feel the abstraction is quite right in the PR because of the way
Yep, I think we will have duplicates, but then internally/semantically I expect they will be quite different. Also I think there's the potential for the presentation to be very different. We can also try extracting some aspects of the implementation to be usable by both. For example the grid layout might be something we consider extracting so the grids always have the same sizing/responsiveness. |
tellthemachines
left a comment
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.
I'm very conflicted about this PR 😅
I love how it simplifies keyboard interaction with the component, vs the DataViews component which is simply painful to navigate.
DataPicker is in a weird place because it's both kind of its own DataView and also kind of just a big complex DataForm. It might help to think about (maybe even try out) some different use-cases for it in order to gauge what its best shape would be. Assuming potential uses like media, posts, templates...? What is it going to help us do? Where will it be really necessary to use this component as opposed to a simple (or multi-) select?
I also wonder if its layouts couldn't be a lot more basic than the DataViews ones given the items in this component are much less interactive. Do we really need anything more than image/preview and title? We might not even need different markup for different layouts; in fact, I'm not sure a listbox should be a table at all. Maybe the only thing we need is to switch between list and grid layouts by changing the display on the parent and on the child items 😺
One use case in the back of my mind is to be able to support browsing from and choosing a page parent for sites with a very large number of pages (e.g. enterprise or large knowledge bases). There's an issue in #69608 that the current approach maxes out at 100 pages, so for larger sites I could imagine the DataPicker in a modal being really handy for being able to browse, search and sort before selecting a parent (particularly since it supports pagination). |
b4e0504 to
9992c14
Compare
packages/dataviews/src/components/datapicker/stories/fixtures.tsx
Outdated
Show resolved
Hide resolved
packages/dataviews/src/components/datapicker/stories/index.story.tsx
Outdated
Show resolved
Hide resolved
|
Hey, I'm trying to understand what's this for and why DataViews can't be used. Would this be a good breakdown of what we need in a picker, or did I miss something?
I'd like to offer an alternative direction that leverages the existing DataViews component instead of creating a new one.
Keyboard navigation: both improvements are useful to DataViews grid independently of what we do with pickers, so it'd be good to have them anyway.
Using the existing DataViews, this is where we stand visually (in red what we need to resolve):
|
|
@oandregal some previous discussions here #70722 (comment) |
|
@youknowriad I saw that but didn't see a breakdown of the specifics. Are we settled on a separate component, or is it open to discussion? Based on the breakdown above and unless I've missed some other task, I don't think it's too hard to make DataViews work in that use case. |
|
I don't think we're totally settled but I'm personally almost there :P The two arguments for me are:
I also know @ellatrix tried to use DataViews list view for a "picker" once (Site picker in calypso I think) and she reverted because it just didn't fit. Curious if you remember the specifics. |
Every layout doesn't have to work for every purpose. That's why we have the configuration. For example, the list layout doesn't work well without a preview and that's fine.
This is just configuration to me: the DataViews' actions prop is a single action with a context. |
Some might be bugs, yet to be implemented or some might work that way for a reason, I don't know the history:
I don't think there's anything that can't be solved, whether it's configuration or a dedicated component. If it's achieved via configuration, the question is how granular that configuration is, and whether we can avoid introducing options that don't make sense when used together. I think that's the main advantage of a separate component is that it can be more prescriptive in its interface.
It's a topic, but I'm not convinced on grid navigation. Not that being able use arrow keys in all directions wouldn't be good, but the aria implementation for grid seems really lacking tbh, and the examples don't seem to fit the use case. I expect screenreader support is terrible too. Those of us that worked on keyboard navigation for ListView in the editor ran into these sorts of issues, and in the end we had to use If there's a simpler option, like making it a list, then it might be an easier starting point. Also, I'm not sure how things like setting a sort order make sense if the thing is semantically a grid. What does it mean to sort a grid. |
…t. Reorder in story to match WordPress dialog button ordering
62f803c to
b948c7a
Compare


What?
Related - #70722
Adds a
DataViewsPickercomponent that's very similar to the regularDataViewscomponent, but is optimized for selection or picking of items.The component behaves differently to a regular
DataViewscomponent in the following ways:listboxandoptionaria roles.ctrlorcmdkey isn't required for multi-selection of items. The entire item can be clicked to select or deselect it.There are also a few differences in the implementation:
pickerGridlayout is supported forDataViewsPicker. This layout looks very similar to the regulargridlayout.selectionandonChangeSelectionshould be provided as props. This is so that implementers can access the full range of selected items across pages.isItemClickable,renderItemLinkandonClickItemprop are unsupported forDataViewsPicker.supportsBulk: true. For single selection usesupportsBulk: false. When a mixture of bulk and non-bulk actions are provided, the component falls back to single selection.callbackstyle of action is supported.RenderModalis unsupported.isEligiblecallback for actions is unsupported.isPrimaryoption for an action is used to render aprimaryvariant ofButtonthat can be used as a main call to action.Testing Instructions
npm run storybook:devDataViews->Pickerstory (once the storybook has built and opens in your browser)Screenshots or screencast
(when clicking finish there's an alert that shows, but it appeared outside the video crop zone 😄 )
Kapture.2025-07-30.at.15.44.34.mp4