Opened 2 months ago
Closed 6 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.
- Go to Media -> Library page.
- Drag a restricted file into the download area (zip, etc.).
- An admin notice should appear that the file type is not allowed.
- 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)
Change History (6)
#2
@
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.
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.