[wp-trac] [WordPress Trac] #51396: [Media upload.php] Switch back from grid to list mode reopen the modal
WordPress Trac
noreply at wordpress.org
Sat Sep 26 11:18:43 UTC 2020
#51396: [Media upload.php] Switch back from grid to list mode reopen the modal
--------------------------+-----------------------------
Reporter: Mista-Flo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Steps to reproduce:
- Go to the media library in grid mode (wp-admin/upload.php?mode=grid)
- Click on an item, you should have something like this in the URL : `wp-
admin/upload.php?item=27&mode=grid`
- Refresh the page
- Close the modal
- Switch to list mode
- Switch back to grid mode
- The modal is now opened with the previous item
This is due because the URL to switch between modes are generated in PHP
`src/wp-includes/media-template.php`, meaning the URL is set once and do
not get updated if there are some dynamic changes in the page.
The code is:
{{{#!php
<?php
<a href="<?php echo esc_url( add_query_arg( 'mode',
'list', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-list">
<span class="screen-reader-text"><?php _e( 'List
view' ); ?></span>
</a>
<a href="<?php echo esc_url( add_query_arg( 'mode',
'grid', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-grid current" aria-
current="page">
<span class="screen-reader-text"><?php _e( 'Grid
view' ); ?></span>
</a>
}}}
So we have to find a better way to handle this I guess, even if it's very
edgecase.
I do not know all URL parameters you can have in this page, so I'm not
sure about the solution, but I think we can just assume to reset any
parameter when switching from one mode to another. If so, then we could
stay in PHP and just print the admin_url of upload.php.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51396>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list