Make WordPress Core

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's profile 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".

Attachments (2)

color-picker_close.diff (696 bytes) - added by gitlost 9 years ago.
In close() check iris exists before attempting to toggle it.
32856.patch (3.2 KB) - added by gitlost 8 years ago.
Refresh with unittest.

Download all attachments as: .zip

Change History (6)

@gitlost
9 years ago

In close() check iris exists before attempting to toggle it.

#1 @gitlost
9 years ago

  • Keywords has-patch added

Still good for 4.4.

#2 in reply to: ↑ description @arpowers
9 years ago

I have the same issue, however, i think we also need to add this same check to the 'open()' function as well inside the colorPicker.

#3 @arpowers
9 years ago

Never mind, i indeed had the same bug. Same fix works, i can't believe it (2 hours later)

@gitlost
8 years ago

Refresh with unittest.

#4 @gitlost
8 years ago

  • Keywords has-unit-tests added
Note: See TracTickets for help on using tickets.