Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#51395 closed defect (bug) (fixed)

The attachment modal is not opened when reloading the page

Reported by: Mista-Flo Owned by: SergeyBiryukov
Priority: normal Milestone: 5.6
Component: Media Version:
Severity: normal Keywords: has-patch dev-feedback
Cc: Focuses: javascript, administration

Description

Hello,

On the media library page, grid mode, if you click on an attachment, it will open a modal. If you refresh the page, the modal will be opened again on the same attachment.

But if you have more than 40 attachments in the page, if you click on the 41st attachment, the modal is opened as expected, but if you refresh the page, you have a console error (Uncaught TypeError: Cannot read property 'set' of undefined) in a JS file and the modal is not opened.

This is due because the code calls item.set( 'skipHistory', true ); in src/js/media/routers/manage.js despite it's not sure the item has been found.

So when moving this line after being sure the item is defined, the error is gone and the modal can be opened without a problem.

Attachments (1)

51395.1.patch​ (594 bytes ) - added by Mista-Flo 6 years ago.

Download all attachments as: .zip

Change History (5)

#1 @mukesh27
6 years ago

  • Focuses administration added
  • Keywords dev-feedback added
  • Version trunk

Hi there,

I have replicated the issue and 51395.1.patch​ patch working fine for WordPress version 5.6-alpha-48958.

Added dev-feedback for dev feedback.

#2 @Mista-Flo
6 years ago

Thank you @mukesh27,

Just to mention that this is due to the fact that at the refresh, it loads the first 40 attachments (check the AJAX request), so the next attachments are not queried which seems legit.

#3 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review → 5.6
  • Owner set to SergeyBiryukov
  • Status new → reviewing

#4 @SergeyBiryukov
6 years ago

  • Resolution → fixed
  • Status reviewing → closed

In 49062:

Media: Check if the item is defined before setting the skipHistory property in media frame router.

This avoids a JS error when refreshing the "Attachment details" modal for an item that is not currently queried.

Follow-up to [41021].

Props Mista-Flo, mukesh27.
Fixes #51395.

Note: See TracTickets for help on using tickets.