Media Upload Modal: Fix pagination and search#77872
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: +88 B (0%) Total Size: 7.87 MB 📦 View Changed
ℹ️ View Unchanged
|
ramonjd
left a comment
There was a problem hiding this comment.
LGTM
I had a question about state persistence but since this PR fixes a pretty nasty bug, it's a good start. Thanks!
Before
Kapture.2026-05-01.at.15.02.21.mp4
After
Kapture.2026-05-01.at.15.03.18.mp4
| slug: 'media-modal', | ||
| defaultView, | ||
| queryParams, | ||
| onChangeQueryParams: setQueryParams, |
There was a problem hiding this comment.
One thing I noticed is that the params persist. So when I reopen the modal with a search or pagination state, that's the first view I see and I have to clear the search/return to the first page if I want to see the start of my lib.
Is that intentional?
There was a problem hiding this comment.
Oh, good catch! It's a quick fix, so I'll update it to clear out when the modal closes, and add a test.
There was a problem hiding this comment.
Fixed in: f882fe9
(I went with a useEffect instead of in handleModalClose as I imagine we want to clear this out both when the modal is closed and when an item is selected and then the modal closes)
|
Flaky tests detected in f882fe9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25203434575
|
|
Thanks for the quick review on this one! 🙇 |
|
I just cherry-picked this PR to the release/23.1 branch to get it included in the next release: 892fef0 |
* Media Upload Modal experiment: Fix pagination * Set query params back to defaults when closing the modal Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
|
Thanks Marin! 🙇 |
What?
Follows:
In the media modal experiment, fix pagination and search. In #77288 we added view persistence, but seemed to have broken pagination and search in the process.
The reason is that
useViewexpects to handlequeryParams(and specificallypageandsearch) separately so that they're not included with the persistent view config. Since we weren't passing inqueryParams, the values were being stripped, which meant that the Next / Prev buttons, etc weren't working in the modal.How?
useViewalong with a callback setter.Testing Instructions
Enable the media upload modal experiment:
Screenshots or screencast
This should work:
2026-05-01.14.47.03.mp4
Use of AI Tools
Codex and Claude Code to verify Codex's fix and tests