Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42475 closed defect (bug) (fixed)

Customize: Autosaving message not sent to preview at first change

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Customize Keywords: has-patch commit dev-reviewed
Focuses: Cc:

Description (last modified by westonruter)

In customize-controls.js there is a startAutosaving function that gets called once a change is first made. It then in turn will start listening for changes to the saved state to then send an autosaving message to the preview when it goes dirty. However, the saved state also gets set to false (dirty) when a change event happens. So there is somewhat of a race condition. This means that the saved state change handler is not getting fired with the first change.

Easy way to see this behavior is to install the customizer-dev-tools plugin and run this from the console:

CustomizerDevTools.startLogging(/autosaving|saved|change/)

You'll see the autosaving message is not sent to the preview after the first change, but it will be sent after saving a draft and making a second change.

Likewise, you can see the problem illustrated by hovering over links in the preview after the first change and see they lack the customize_autosaved=on parameter. However, after saving a draft and making a second change, then you'll see the param appear.

Attachments (1)

42475.diff (832 bytes) - added by westonruter 7 years ago.

Download all attachments as: .zip

Change History (7)

@westonruter
7 years ago

#1 @westonruter
7 years ago

  • Description modified (diff)
  • Keywords has-patch needs-testing added

The solution is simply to call handler for saved state change when startAutosaving is being called. See 42475.diff.

#2 @bpayton
7 years ago

I was able to reproduce the behavior and observe that the patch corrects it. The change looks good to me.

#3 @westonruter
7 years ago

  • Keywords dev-feedback commit added; needs-testing removed

#4 @jeremyfelt
7 years ago

  • Keywords dev-reviewed added; dev-feedback removed

I was confused by the reported issue at first, but the customizer-dev-tools plugin was super useful.

42475.diff looks good. +1 for commit.

#5 @westonruter
7 years ago

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

In 42136:

Customize: Ensure autosaving message gets sent to preview after initial change when saved state is first dirty.

Amends [41667].
Fixes #42475 for trunk.

#6 @westonruter
7 years ago

In 42137:

Customize: Ensure autosaving message gets sent to preview after initial change when saved state is first dirty.

Amends [41667].
Fixes #42475 for 4.9.

Note: See TracTickets for help on using tickets.