BlueGit

timfa questward

Keep focus when editing dialogue item-take quantities.

Quantity changes only refresh yellow path warnings instead of rebuilding the whole editor.

timfa Tim Falken · pushed by timfa

Authored 2026-09-07 · 2 months ago

Hash
da4a64d7a978cc4516adc0d8fa8be6255a5486e1
Parent
a23e961c
1 file changed +21 −1
client/src/editor/dialoguesModal.js +21 −1
@@ -172,6 +172,24 @@ export function initDialoguesModal ({
172 172 renderEditor();
173 173 }
174 174
175 /** Update yellow take warnings without rebuilding the editor (keeps scroll + focus). */
176 function refreshDialogueTakeHighlights ()
177 {
178 if (!draft || !editorEl)
179 { return; }
180 const warnings = unguaranteedDialogueTakes(draft);
181 for (const row of editorEl.querySelectorAll("[data-take-step-id][data-take-item-id]"))
182 {
183 const stepId = row.getAttribute("data-take-step-id");
184 const itemId = Number(row.getAttribute("data-take-item-id"));
185 const bad = dialogueTakeIsUnguaranteed(warnings, stepId, itemId);
186 row.classList.toggle("dialogue-item-take-unguaranteed", bad);
187 row.title = bad
188 ? "Not guaranteed by every branch/trigger path to this step."
189 : "";
190 }
191 }
192
175 193 function renderEditor ()
176 194 {
177 195 editorEl.replaceChildren();
@@ -373,6 +391,8 @@ export function initDialoguesModal ({
373 391 const def = itemDefinition(take.itemId);
374 392 const row = document.createElement("div");
375 393 row.className = "spawner-drops-row";
394 row.setAttribute("data-take-step-id", step.stepId);
395 row.setAttribute("data-take-item-id", String(take.itemId));
376 396 if (dialogueTakeIsUnguaranteed(takeWarnings, step.stepId, take.itemId))
377 397 {
378 398 row.classList.add("dialogue-item-take-unguaranteed");
@@ -390,7 +410,7 @@ export function initDialoguesModal ({
390 410 qty.addEventListener("input", () =>
391 411 {
392 412 step.itemTakes[takeIndex].quantity = Math.max(1, Number(qty.value) || 1) | 0;
393 renderEditor();
413 refreshDialogueTakeHighlights();
394 414 });
395 415 row.append(name, qty, removeButton(() =>
396 416 {
@@ -172,6 +172,24 @@ export function initDialoguesModal ({
172 renderEditor();
172 renderEditor();
173 }
173 }
174
174
175 /** Update yellow take warnings without rebuilding the editor (keeps scroll + focus). */
176 function refreshDialogueTakeHighlights ()
177 {
178 if (!draft || !editorEl)
179 { return; }
180 const warnings = unguaranteedDialogueTakes(draft);
181 for (const row of editorEl.querySelectorAll("[data-take-step-id][data-take-item-id]"))
182 {
183 const stepId = row.getAttribute("data-take-step-id");
184 const itemId = Number(row.getAttribute("data-take-item-id"));
185 const bad = dialogueTakeIsUnguaranteed(warnings, stepId, itemId);
186 row.classList.toggle("dialogue-item-take-unguaranteed", bad);
187 row.title = bad
188 ? "Not guaranteed by every branch/trigger path to this step."
189 : "";
190 }
191 }
192
175 function renderEditor ()
193 function renderEditor ()
176 {
194 {
177 editorEl.replaceChildren();
195 editorEl.replaceChildren();
@@ -373,6 +391,8 @@ export function initDialoguesModal ({
373 const def = itemDefinition(take.itemId);
391 const def = itemDefinition(take.itemId);
374 const row = document.createElement("div");
392 const row = document.createElement("div");
375 row.className = "spawner-drops-row";
393 row.className = "spawner-drops-row";
394 row.setAttribute("data-take-step-id", step.stepId);
395 row.setAttribute("data-take-item-id", String(take.itemId));
376 if (dialogueTakeIsUnguaranteed(takeWarnings, step.stepId, take.itemId))
396 if (dialogueTakeIsUnguaranteed(takeWarnings, step.stepId, take.itemId))
377 {
397 {
378 row.classList.add("dialogue-item-take-unguaranteed");
398 row.classList.add("dialogue-item-take-unguaranteed");
@@ -390,7 +410,7 @@ export function initDialoguesModal ({
390 qty.addEventListener("input", () =>
410 qty.addEventListener("input", () =>
391 {
411 {
392 step.itemTakes[takeIndex].quantity = Math.max(1, Number(qty.value) || 1) | 0;
412 step.itemTakes[takeIndex].quantity = Math.max(1, Number(qty.value) || 1) | 0;
393 renderEditor();
413 refreshDialogueTakeHighlights();
394 });
414 });
395 row.append(name, qty, removeButton(() =>
415 row.append(name, qty, removeButton(() =>
396 {
416 {