Commit ·
1bc8988
1
Parent(s): df3bd13
Fix regen: capture pending slot/idx before hidePopup clears them
Browse filesRoot cause: document addEventListener with capture=true fired BEFORE
button onclick, so _pendingSlot was already null when fireRegen ran.
Fix: save slot/idx to locals first, use bubble phase on doc listener.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -1705,13 +1705,15 @@ _GLOBAL_JS = """
|
|
| 1705 |
'border-radius:4px;padding:5px 14px;font-size:12px;cursor:pointer;width:100%;">⟳ Regenerate</button>';
|
| 1706 |
document.body.appendChild(_popup);
|
| 1707 |
document.getElementById('_wf_popup_btn').onclick = function(e) {
|
| 1708 |
-
e.stopPropagation();
|
| 1709 |
-
|
| 1710 |
-
fireRegen(_pendingSlot, _pendingIdx);
|
| 1711 |
-
}
|
| 1712 |
hidePopup();
|
|
|
|
|
|
|
|
|
|
| 1713 |
};
|
| 1714 |
-
|
|
|
|
| 1715 |
return _popup;
|
| 1716 |
}
|
| 1717 |
|
|
|
|
| 1705 |
'border-radius:4px;padding:5px 14px;font-size:12px;cursor:pointer;width:100%;">⟳ Regenerate</button>';
|
| 1706 |
document.body.appendChild(_popup);
|
| 1707 |
document.getElementById('_wf_popup_btn').onclick = function(e) {
|
| 1708 |
+
e.stopPropagation(); // prevents the document bubble-phase listener below from firing
|
| 1709 |
+
var slot = _pendingSlot, idx = _pendingIdx; // capture before hidePopup clears them
|
|
|
|
|
|
|
| 1710 |
hidePopup();
|
| 1711 |
+
if (slot !== null && idx !== null) {
|
| 1712 |
+
fireRegen(slot, idx);
|
| 1713 |
+
}
|
| 1714 |
};
|
| 1715 |
+
// Use bubble phase (false) so stopPropagation() on the button click prevents this from firing
|
| 1716 |
+
document.addEventListener('click', function() { hidePopup(); }, false);
|
| 1717 |
return _popup;
|
| 1718 |
}
|
| 1719 |
|