churchthemes / church-theme-framework

A library of code useful for developing church WordPress themes that use the Church Content plugin.
https://churchthemes.com/guides/developer/framework/
GNU General Public License v2.0
31 stars 13 forks source link

Widget color field doesn't update value until second selection #12

Closed stevengliebe closed 3 years ago

stevengliebe commented 8 years ago

When using 'color' field type on a widget, the initial selection in the color picker doesn't update hex value. Subsequent selections do update.

Works immediately when removing change throttle from ctfw_init_widget_colorpicker() in admin-widgets.js but then Customizer refresh doesn't happen on change.

https://github.com/churchthemes/church-theme-framework/blob/master/js/admin-widgets.js#L214

Any thoughts, @andywilkerson? I think it'll be perfect if we can work this out.

Reference pull request #11

andywilkerson commented 8 years ago

My version is without the 'change throttle' and it seems to show updates in the Customizer right away.

When I open the picker initially and click a color, the hex value is changing in the text input, but the color preview is not showing the setting. If I drag the color or click a second time on the color area it seems to update both the hex and color preview. It's only the very first click where I'm seeing it not react.

stevengliebe commented 8 years ago

Are you sure your version isn't using the change throttle? It was in the pull request at https://github.com/churchthemes/church-theme-framework/pull/11/files#diff-73cf1b3a54a80b874dd3dc6cabdd49fbR17

I saw this discussion about it: https://wordpress.org/support/topic/wp-color-picker-change-event

andywilkerson commented 8 years ago

You're correct, I do have it. I'm going to pull the update from the repo and test it. I'm still using the original code.

andywilkerson commented 8 years ago

I tried a number of alternatives but nothing solved the issue. No matter what changes I applied, I couldn't get the refresh to happen on Customizer without the first click on the color pallet being ignored.

stevengliebe commented 8 years ago

It's a bit strange. I'll give it a look if I ever end up using the color field. Feel free to dig in in the meantime if you want to perfect this part. It's still usable as it is, wouldn't you say? It's natural to make a second click when something doesn't work at first. I would think most users will try a series of colors before deciding on one.

andywilkerson commented 8 years ago

It was so subtle at first, I thought I had miss-clicked until you pointed out the issue. I think people will have no trouble. It's very unlikely anyone gets the exact color they want on their first click. Adjusting a color is going to require multiple clicks, it's almost a guarantee.

Seeing as it's a know issue in the Customizer and impacts all instances of the WP color picker it may be solved in the near future.

stevengliebe commented 8 years ago

Yeah, I'm happy to let it sit.

Thanks for adding the field.