fix(options): swatch-click outline moves even if a change handler throws
Row 122 follow-up: the outline followed dropdown changes (delegated document
handler, native events bubble) but not swatch clicks — the click handler did
sel.val(mode).trigger('change'); refreshAll();, and when the synthetic change
chain throws on the real page, jQuery aborts the rest of the click handler, so
refreshAll() never ran. Now the click handler sets the value and refreshes
FIRST, then fires trigger('change') inside try/catch. OPTIONS_JS_TOKEN ->
20261126.5. jsdom regression test: a throwing change handler on the select + chip
click still moves the outline (plus the existing dropdown/other assertions).
Suite 6/6, export 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
1c89032339
commit
8a6cf1f919
1 changed files with 11 additions and 5 deletions
|
|
@ -788,10 +788,16 @@ var ThemeOptions = function () {
|
|||
var item = $('<span class="color-chip-item"></span>');
|
||||
var chip = $('<button type="button" class="color-chip" data-mode="' + mode + '"></button>');
|
||||
var lbl = $('<span class="color-chip-label"></span>');
|
||||
// refreshAll() is called directly too: a throwing EARLIER direct
|
||||
// change handler (e.g. updateFieldSettings on the real page) aborts
|
||||
// jQuery's synthetic dispatch, and then the outline would not move
|
||||
chip.on('click', function () { sel.val(mode).trigger('change'); refreshAll(); });
|
||||
// row 122: set the value and refresh FIRST, then fire change inside
|
||||
// try/catch — a throwing handler in the synthetic change chain aborts
|
||||
// the rest of this click handler, and without this the outline would
|
||||
// not move when clicking a swatch (while the dropdown works via the
|
||||
// delegated document handler, because native events still bubble).
|
||||
chip.on('click', function () {
|
||||
sel.val(mode);
|
||||
refreshAll();
|
||||
try { sel.trigger('change'); } catch (e) { /* save re-serializes anyway */ }
|
||||
});
|
||||
item.append(chip).append(lbl);
|
||||
chips.append(item);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue