#34738 closed defect (bug) (fixed)
Customizer preview elements lose or misplace their preview data
Reported by: | Clorith | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Customize | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
As first reported by @pagelab in https://wordpress.org/support/topic/inconsistent-behavior-of-javascript-clickchange-events-in-the-customizer
When making changes to widget settings in the customizer, they will forget (and "reset") the other changes made except the most recent one when generating the preview.
Reproducible with weird outcomes:
Add a Text widget
Write a title, preview updates with the title as expected
Write some content, preview updates with the content but removes the title.
You can also remove the title, but the preview keeps the title, and mix and match as you please it seems, some times it will include the data though (tested with twenty fifteen, no active widgets and the text widget from core)
Attachments (3)
Change History (20)
#2
@
9 years ago
- Milestone changed from Awaiting Review to 4.4
- Owner set to westonruter
- Status changed from new to accepted
- Version changed from trunk to 4.3
I am seeing the issue clearly with the toggles in the “Simple widget” as linked to from the support forum. With further testing, I'm able to reproduce the issue with Text widget as well. I'm trying to isolate where the regression is.
#5
@
9 years ago
- Keywords has-patch needs-testing needs-unit-tests dev-feedback added
In 34738.0.diff:
- Move
$is_previewed
fromWP_Customize_Setting
child classes to parent. - Introduce
customize_post_value_set
andcustomize_post_value_set_{$setting_id}
actions. Use to defer callingWP_Customize_Setting::preview()
until it has a value to set, and to clear out the previewed-applied flag for a multidimensional-aggregated value whenever its post value is updated. - Ensure that a multidimensional setting's post value is applied to preview if the setting is previewed.
- Ensure that a widget instance's JS value is set as the post value.
Needs new unit tests to cover the new scenarios.
#6
@
9 years ago
@valendesigns Please review my PR as it is. I need to follow up with unit tests still.
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
#10
@
9 years ago
Seeing expected behavior when applying 34738.0.diff
Texts are going where they should, and I am not able to make it retain removed text inputs like before.
#11
@
9 years ago
Yes, I also confirm that is working as expected now with 34738.0.diff applied. Tested with the same "Simple Widget" plugin as before.
#12
@
9 years ago
- Keywords needs-testing removed
@westonruter the patch looks good, and is also working for me using the test widget.
@pagelab Your test widget has a couple errors I had to fix before I could use it since my environment is in debug mode. The most important being that you can't convert $instance
to a string. So you're CSS id should be something like this $id = "{$this->id_base}-toggle-{$this->number}";
. The other two are on line 58 & 149 $instance['title']
doesn't exist when you first create a widget so you need to do a ternary isset
check like so $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
to avoid PHP warnings. At any rate, thank you for supplying something to test with.
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
@
9 years ago
Additional changes: https://github.com/xwp/wordpress-develop/compare/3ee37d1...c2fabed
#15
@
9 years ago
- Keywords commit added; needs-unit-tests dev-feedback removed
In 34738.1.diff:
- Add unit tests, including new assertions for
WP_Customize_Setting::preview()
for scalar, multidimensional, and custom types - Add unit tests for
WP_Customize_Manager::set_post_value()
and the related actions. - Add unit tests for
WP_Customize_Widgets::call_widget_update()
. - Use
customize_post_value_set_{setting_id}
instead of generalcustomize_post_value_set
to clear_aggregated_multidimensional_preview_applied_flag. - Remove obsolete
WP_Customize_Setting::value()
call toapply_multidimensional_preview_value()
call since now handled automatically via deferred-preview, and remove the newapply_multidimensional_preview_value()
method since it is no longer needing to be called separately (due to deferred-preview being applied oncustomize_post_value_set
action).
@
9 years ago
Do customize_post_value_set before customize_post_value_set_{setting_id}: https://github.com/xwp/wordpress-develop/commit/268a38778f0b925a5d34a86ac458029b12eff4fe
@Clorith I'm not seeing this issue with the Text widget.
Here is what I see in 4.4 beta 4 at r35701: https://cloudup.com/cAz3UhFnOQa