WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#51396 new defect (bug)

[Media upload.php] Switch back from grid to list mode reopen the modal

Reported by: Mista-Flo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.0
Component: Media Keywords: has-patch
Focuses: administration Cc:

Description

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
                <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.

Attachments (1)

51396.1.patch (1.1 KB) - added by Mista-Flo 5 weeks ago.
Fix with PHP

Download all attachments as: .zip

Change History (5)

@Mista-Flo
5 weeks ago

Fix with PHP

#1 @Mista-Flo
5 weeks ago

  • Component changed from General to Media
  • Focuses administration added
  • Keywords has-patch added
  • Version changed from trunk to 4.0

This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.


5 weeks ago

#3 @mukesh27
5 weeks ago

Hi there!

51396.1.patch patch working fine for me.

This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.


4 weeks ago

Note: See TracTickets for help on using tickets.