WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#38592 closed defect (bug) (fixed)

Customizer preview fails to persist state query params through history.pushState() calls

Reported by: westonruter Owned by: westonruter
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

There is a typo in [38810] for #30937 where the injectUrlWithState method fails to return the new state URL that is mutated. It is capturing the state data but it is not ensuring the URL gets the state params.

Also, if the history.pushState() or history.replaceState() call is done before the preview-ready event triggers, then a JS error is likely to result because wp.customize.settings would not be defined yet. It is unnecessary to define anyway because the query params are in the URL to begin with anyway.

Change History (1)

#1 @westonruter
3 years ago

  • Owner set to westonruter
  • Resolution set to fixed
  • Status changed from new to closed

In 39060:

Customize: Ensure state query params persist in preview through calls to history.pushState() & history.replaceState().

Allow history to be manipulated before DOM ready by sourcing state params from the current URL instead of from the wp.customize.settings object, since they will be the same anyway. This fixes a JS error since wp.customize.settings is not defined before DOM ready.

Amends [38810].
See #30937.
Fixes #38592.

Note: See TracTickets for help on using tickets.