Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#36018 closed defect (bug) (fixed)

Ensure autofocus for dynamically-created panels, sections, and controls

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.1
Component: Customize Keywords: has-patch commit
Focuses: javascript Cc:


At the moment, autofocus via URL params (#28650) only works for panels, sections, and controls which are defined statically up-front. Any constructs not created statically will be stripped from exporting to JS. Additionally, from the JS side, if any of these constructs do not exist by ready, they will also be ignored.

Autofocus should work for anything that gets created with JS.

Attachments (3)

36018.0.diff (2.1 KB) - added by westonruter 8 years ago.
36018.1.diff (2.2 KB) - added by westonruter 8 years ago.
Clean up comment
36018.2.diff (2.7 KB) - added by westonruter 8 years ago.
Further simplify

Download all attachments as: .zip

Change History (6)

8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch added
  • Owner set to westonruter
  • Status changed from new to accepted

See 36018.0.diff.

The PHP logic for calculating $can_autofocus is being over zealous in its checks. If the panel, section, or control doesn't exist on the JS side (due to not existing or due to a capability failure), there will not be anything to focus on.

8 years ago

Clean up comment

#2 @westonruter
8 years ago

  • Keywords commit added

8 years ago

Further simplify

#3 @westonruter
8 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 36796:

Customize: Ensure autofocus deep-linking applies for dynamically-created panels, sections, and controls.

Removes overly-zealous filtering of autofocus panels, sections, and controls which are unrecognized or for which the user doesn't have the capability to focus (in which case it would no-op anyway). Also defers autofocus logic until instances are created, even after initial ready event. This ensures that autofocus can apply for any panels, sections, or controls that get created via the loaded preview.

See #28650.
Fixes #36018.

Note: See TracTickets for help on using tickets.