WordPress.org

Make WordPress Core

Opened 12 days ago

Last modified 11 days ago

#48021 new defect (bug)

Dismissing notice on the media library triggers error in console

Reported by: desrosj Owned by:
Milestone: 5.2.4 Priority: normal
Severity: minor Version: 5.2.3
Component: Media Keywords: has-patch
Focuses: javascript, administration Cc:

Description

When viewing the media library, clicking the dismiss X on an admin notice triggers a TypeError warning in the console.

TypeError: this.controller.modal is undefined ... media-views.js5326

Steps I have been using to trigger.

  1. Go to Media -> Library page.
  2. Drag a restricted file into the download area (zip, etc.).
  3. An admin notice should appear that the file type is not allowed.
  4. Open browser console and observe the error when the X is clicked on the notice.

The error does not appear to cause any odd behavior after it happens.

Attachments (1)

48021.diff (512 bytes) - added by afercia 11 days ago.

Download all attachments as: .zip

Change History (3)

#1 @afercia
11 days ago

Likely caused by [45376] / #47113. Would need a simple check before calling focusManager.focus().

Could also be addressed in #43169 which I left as an open task to catch edge cases related to focus management in the media views.

@afercia
11 days ago

#2 @afercia
11 days ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.2.4
  • Version set to 5.2.3

At the moment, wp.media.view.FocusManager is initialized only on the media modal.

48021.diff seems the simpler way to fix this issue.

Noting that on other tickets related to the media views, for example in #47149, I'm proposing to make the FocusManager a more useful tool for general focus management methods to be reused across all the media views.

There are cases where focus needs to be managed also outside of the modal. For example in this case, when pressing the Dismiss error button, there's a focus loss that should be prevented. For the future, I'm considering to initialize FocusManager on the media frame so that it should be available everywhere. For now, 48021.diff should solves this specific error.

Setting the milestone to 5.2.4 as it's a small, self-contained fix. Please do feel free to change it if not appropriate.

Note: See TracTickets for help on using tickets.