[wp-trac] [WordPress Trac] #43169: Media views: avoid to move focus programmatically when not strictly necessary

WordPress Trac noreply at wordpress.org
Mon Jan 29 15:38:10 UTC 2018


#43169: Media views: avoid to move focus programmatically when not strictly
necessary
-------------------------------------+-------------------------------------
 Reporter:  afercia                  |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Media                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-screenshots has-     |     Focuses:  ui, accessibility,
  patch dev-feedback                 |  javascript
-------------------------------------+-------------------------------------
Changes (by afercia):

 * keywords:  has-screenshots => has-screenshots has-patch dev-feedback


Comment:

 Typically, the cases where managing focus programmatically is necessary
 are:
 - when opening and closing the media modal
 - then the media modal view changes and its whole contant re-renders
 - when adding or deleting attachments

 [attachment:43169.diff] is a first pass
 - keeps focus management in the cases above and in a few other cases that
 make sense
 - removes any other usage of `focus()`
 - makes the edit-attachment navigation buttons really disabled when there
 are no next or previous attachments
 - tries to clarify with inline comments all the usages of `focus()`

 There are a couple issues to address yet, most notably when `MEDIA_TRASH`
 is set to true, when deleting attachments from the Media Library, the view
 is re-queried and reset. This makes difficult to restore focus in a proper
 place and would probably need an event that fires at the end of the view
 re-rendering or something similar. Any help very welcome.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43169#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list