[wp-trac] [WordPress Trac] #32667: Customizer: autofocus should load as soon as the panel/section/control is active

WordPress Trac noreply at wordpress.org
Wed Jul 15 20:32:40 UTC 2015


#32667: Customizer: autofocus should load as soon as the panel/section/control is
active
------------------------------+-----------------------------
 Reporter:  celloexpressions  |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Future Release
Component:  Customize         |     Version:  trunk
 Severity:  normal            |  Resolution:
 Keywords:  needs-patch       |     Focuses:  javascript
------------------------------+-----------------------------
Changes (by westonruter):

 * milestone:  4.3 => Future Release


Comment:

 The logic in `customize-controls.js` that handles the expansion:

 {{{#!js
 // Focus the autofocused element
 _.each( [ 'panel', 'section', 'control' ], function ( type ) {
         var instance, id = api.settings.autofocus[ type ];
         if ( id && api[ type ]( id ) ) {
                 instance = api[ type ]( id );
                 // Wait until the element is embedded in the DOM
                 instance.deferred.embedded.done( function () {
                         // Wait until the preview has activated and so
 active panels, sections, controls have been set
                         api.previewer.deferred.active.done( function () {
                                 instance.focus();
                         });
                 });
         }
 });
 }}}

 So you can see that it waits until the panel, section, or control is
 embedded into the document until it focuses on the element. If we wanted
 to make it so that the top-level sections aren't shown at the initial
 load, then we should probably hide the pane and show a spinner, and wrap
 the `focus` call in an `expand` call with a `duration` of `0` to skip the
 animation, for instance:

 {{{#!js
 instance.expand({
     completeCallback: function() {
         instance.focus();
     },
     duration: 0
 });
 }}}

 There's too much work to do here for 4.3 I think, so it should be punted.
 Also this it is going to be heavily impacted by #28580 since if we're
 requesting `autofocus` of a certain section, then the controls and their
 settings in the section should be pre-loaded up-front. If there is no
 autofocus, then we can defer the loading of the controls/settings until
 the section is expanded.

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


More information about the wp-trac mailing list