diff --git a/src/rolls/check-factory.ts b/src/rolls/check-factory.ts index ed714375..99f87216 100644 --- a/src/rolls/check-factory.ts +++ b/src/rolls/check-factory.ts @@ -126,6 +126,7 @@ async function askForInteractiveRollData( ): Promise> { const usedTemplate = template ?? "systems/ds4/templates/dialogs/roll-options.hbs"; const usedTitle = title ?? getGame().i18n.localize("DS4.DialogRollOptionsDefaultTitle"); + const id = foundry.utils.randomID(); const templateData = { title: usedTitle, checkTargetNumber: checkTargetNumber, @@ -141,6 +142,7 @@ async function askForInteractiveRollData( } return { value: key, label: translation }; }), + id, }; const renderedHtml = await renderTemplate(usedTemplate, templateData); @@ -183,8 +185,10 @@ async function askForInteractiveRollData( }, { activateAdditionalListeners: (html, app) => { - const checkModifierCustomFormGroup = html.find("#check-modifier-custom").parent(".form-group"); - html.find("#check-modifier").on("change", (event) => { + const checkModifierCustomFormGroup = html + .find(`#check-modifier-custom-${id}`) + .parent(".form-group"); + html.find(`#check-modifier-${id}`).on("change", (event) => { if ( (event.currentTarget as HTMLSelectElement).value === "custom" && checkModifierCustomFormGroup.hasClass("ds4-hidden") @@ -197,6 +201,7 @@ async function askForInteractiveRollData( } }); }, + id, }, ).render(true); }); diff --git a/templates/dialogs/roll-options.hbs b/templates/dialogs/roll-options.hbs index cf67c2a0..a2dfcef4 100644 --- a/templates/dialogs/roll-options.hbs +++ b/templates/dialogs/roll-options.hbs @@ -13,18 +13,18 @@ SPDX-License-Identifier: MIT !-- @param rollMode: The preselected roll mode (= chat roll-mode). !-- @param rollModes: A map of all roll modes and their i18n keys. !-- @param checkModifiers: A map of all check difficulty modifiers and their translations. +!-- @param id: A unique id, used to provided uniqe ids for input elements. --}}
- - {{localize "DS4.DialogRollOptionsCheckTargetNumberLabel"}} +
- +
- {{log checkModifiers}} - {{#select "0"}} {{#each checkModifiers as |checkModifier|}} @@ -34,24 +34,24 @@ SPDX-License-Identifier: MIT
- - {{localize "DS4.DialogRollOptionsCheckModifierCustomLabel"}} +
- - {{localize "DS4.DialogRollOptionsMaximumCoupResultLabel"}} +
- - {{localize "DS4.DialogRollOptionsMinimumFumbleResultLabel"}} +
- +
- {{#select rollMode}} {{#each rollModes as |rollModeValue rollModeKey|}}