fixed open #id_tray obscuring role select FTs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-03-29 23:46:23 -04:00
parent fb782cf5ef
commit 299a806862
2 changed files with 20 additions and 18 deletions

View File

@@ -1,4 +1,8 @@
var RoleSelect = (function () {
// Set to true by handleTurnChanged so that a WS turn_changed that races
// ahead of the fetch response doesn't get overridden by Tray.open().
var _turnChangedBeforeFetch = false;
var ROLES = [
{ code: "PC", name: "Player", element: "Fire" },
{ code: "BC", name: "Builder", element: "Stone" },
@@ -24,6 +28,7 @@ var RoleSelect = (function () {
}
function selectRole(roleCode, cardEl) {
_turnChangedBeforeFetch = false; // fresh selection, reset the race flag
var invCard = cardEl.cloneNode(true);
invCard.classList.add("flipped");
// strip old event listeners from the clone by replacing with a clean copy
@@ -70,7 +75,8 @@ var RoleSelect = (function () {
trayCard.dataset.role = roleCode;
grid.insertBefore(trayCard, grid.firstChild);
}
if (typeof Tray !== "undefined") {
// Only open if turn_changed hasn't already arrived and closed it.
if (typeof Tray !== "undefined" && !_turnChangedBeforeFetch) {
Tray.open();
}
}
@@ -164,6 +170,8 @@ var RoleSelect = (function () {
if (invSlot) invSlot.innerHTML = "";
// Force-close tray instantly so it never obscures the next player's card-stack.
// Also set the race flag so the fetch .then() doesn't re-open if it arrives late.
_turnChangedBeforeFetch = true;
if (typeof Tray !== "undefined") Tray.forceClose();
var stack = document.querySelector(".card-stack[data-user-slots]");