-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support bulk selection by default for every block #406
base: trunk
Are you sure you want to change the base?
Conversation
Test this PR in WordPress Playground. |
On it! Thanks |
I have a few related comments about it in #369 after @alecgeatches pointed this out. This is the behaviour in the uncontrolled component, where I don't think the underlying state is correct? It only seems to be possible when using But to me, it seems unintentional in the uncontrolled component, and it would be worth checking to see if that's the case or if it's a bug that needs to be reported. So I can follow up with that. |
This PR changes the implementation to be a controlled component, see |
It is controlled in trunk / from #369, and the selections are preserved there: Screen.Recording.2025-03-05.at.8.28.33.PM.movIf this is what you are referring to. I can't replicate this in this branch, so I think some changes removed the behaviour. |
Silly me, this has nothing to do with DataViews. This is because the UUIDs attached to each result are changing on page navigation because the results are being re-fetched. I will add some memoization to the underlying fetch which will both fix this issue and improve performance. Thanks @brookewp for awesome feedback and detail as always! |
Now that the remote data results contain type information that was previously stripped out, @brookewp and I agreed that using the first result to introspect the DataViews columns instead of I've made this change in 14547fd This effectively means that we are using the output schema of the selection query to display data in DataViews instead of the output schema of the render query. This also fixes #396 as a side-bonus. |
It looks like it's not possible to 'Choose' a single item anymore, and results aren't being saved to the front end: Screen.Recording.2025-03-07.at.12.06.10.PM.movI ran into the second issue when implementing bulk selection, but it was just when there were multiple items and not single items, too. I can look back at what happened there and share if it's helpful. |
Note
This pull request is large, mostly because the changes it makes affect server-side config schema, query execution, and block bindings as well as client-side rendering, data curation, and data fetching logic. I recommend reviewing by commit.
The initial motivation for this pull request was to revisit a few issues found when reviewing #369:
supports_bulk
property could only be successfully applied to ID fields, but there was no enforcement of this.These issues were relatively minor, but as @brookewp and I discussed it, we realized that there were some architectural decisions that probably needed revisiting. Doing so would fix the above issues and allow bulk selection for any query type, not just those that opted-in.
They also pave the way for removing "loop" blocks entirely, since both "single" and "loop" blocks are now rendering in the same fundamental way. That work is left for a future PR.
Significant changes in this PR
QueryRunner
and REST API endpoint. This reduces boilerplate in both server-side and client-side code to loop over multiple requests.id:list
input variable type, it can be resolved by a single query. Otherwise the query is repeated for each selected item.That's a lot! The result is more consistency and type safety and better capabilities around batch querying. Here's a short video of multi-select for a block that has done absolutely nothing to opt-in:
Screen.Recording.2025-03-05.at.17.31.30.mov
Known issues