Opened 9 years ago
Last modified 5 years ago
#32856 new defect (bug)
wpColorPicker close should check that iris hasn't been destroyed before toggling it.
Reported by: | gitlost | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | General | Keywords: | has-patch has-unit-tests |
Focuses: | javascript | Cc: |
Description
wpColorPicker.close() can be called (via the 'click.wpcolorpicker' event on body) when the internally used iris widget has already been destroyed, which means that when it attempts to toggle iris an exception is thrown. The attached patch just checks that iris still exists before the toggle is attempted.
This issue arose in response to the question "Modify Custom Field in Media Library using JavaScript" by @Howdy_McGee on Wordpress Development stackexchange http://wordpress.stackexchange.com/questions/193006/modify-custom-field-in-media-library-using-javascript, which can be used to replicate the scenario. If you open the color picker and then, leaving it open, close the Attachment Details modal window, a $.error exception is thrown (or can be - may depend on your system) by jQuery UI Widget, "cannot call methods on iris prior to initialization".
In close() check iris exists before attempting to toggle it.