WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 2 weeks ago

#34436 new defect (bug)

Issue with wp.customizer.panel('name').focus().

Reported by: wpweaver Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.3.1
Component: Customize Keywords: good-first-bug has-patch
Focuses: javascript Cc:

Description

This is a small bug (feature?) when using wp.customizer.panel('panel-name').focus().

If you have a Section open (the options being displayed), wp.customizer.panel('parent-of-that-section').focus(); will not switch focus from the section display to the parent panel. Using wp.customizer.panel('any-other-panel').focus(); works.

My new theme interface builds an auxiliary menu to more easily navigate all the panels and sections, and it all works nicely except this case.

I can provide a beta of my theme that demos this if needed. This is likely not really critical, but it does not work as one would expect. This issue manifests in both 4.3.1 and 4.4 beta 1.

Attachments (1)

#34436 - With PR #1322.gif (844.7 KB) - added by costdev 2 weeks ago.
#34436 - With PR #1322

Download all attachments as: .zip

Change History (8)

#1 @celloexpressions
5 years ago

  • Keywords needs-patch added

Essentially, the issue here is that focus() doesn't work to move from a section to its parent panel. That should be a case we can fix, if someone can dig into that code.

It sounds like for your use case it may be more appropriate to use section|panel.expand()/collapse() directly. But I think we should be able to add a check to focus out of a section to a parent panel.

#2 @westonruter
5 years ago

  • Milestone changed from Awaiting Review to Future Release

#3 @celloexpressions
4 weeks ago

  • Focuses javascript added
  • Keywords good-first-bug added
  • Milestone set to Future Release

This should be a relatively straightforward bug to patch. Likely a matter of adding a conditional to the panel.focus() JS method that closes any open sections.

To test: open the customizer to editing a specific menu. Enter this into the browser console: wp.customize.panel( 'nav_menus' ).focus();. Expected behavior is for the menu to close and the list of menus (top-level menu panel) to appear.

This ticket was mentioned in PR #1322 on WordPress/wordpress-develop by costdev.


3 weeks ago

  • Keywords has-patch added; needs-patch removed

Look for an expanded section whose panel param matches construct.id.
If one is found, collapse it.

Fixes #34436

Trac ticket: https://core.trac.wordpress.org/ticket/34436

#5 @costdev
3 weeks ago

I've just submitted a patch for this bug.

Apologies for the second commit - I had mistakenly added the code block to the bottom of the focus function in an effort to keep things tidy, without noticing that focusElement.focus() was already called by this point, rendering the code block useless. I've moved it to the top of the focus function so as not to disrupt the smooth sequence of declaration and usage of focusContainer and focusElement.

#6 @costdev
3 weeks ago

Javascript coding standards test failed. I've updated the patch to correct this.

#7 @costdev
2 weeks ago

I've attached a GIF showing the result of the patch. This issue seems to be fixed.

Note: See TracTickets for help on using tickets.