WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 8 weeks ago

#48021 closed defect (bug) (fixed)

Dismissing notice on the media library triggers error in console

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

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 2 months ago.

Download all attachments as: .zip

Change History (6)

#1 @afercia
2 months 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
2 months ago

#2 @afercia
2 months 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 solve 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.

Last edited 8 weeks ago by afercia (previous) (diff)

#3 @desrosj
8 weeks ago

Thanks, @afercia. I tested this and it fixes the problem for me. I'd say this can go into trunk and moved to 5.3 since there is no 5.2.4 planned before then.

#4 @desrosj
8 weeks ago

  • Milestone changed from 5.2.4 to 5.3

#5 @afercia
8 weeks ago

  • Owner set to afercia
  • Resolution set to fixed
  • Status changed from new to closed

In 46321:

Media: Fix JavaScript TypeError after [45376].

Props desrosj, afercia.
Fixes #48021.

Note: See TracTickets for help on using tickets.