fix: make the HTML ids in the roll options dialog unique

This commit is contained in:
Johannes Loher 2022-05-13 19:23:18 +02:00
parent 82217dd971
commit a94fb55e19
2 changed files with 20 additions and 15 deletions

View file

@ -126,6 +126,7 @@ async function askForInteractiveRollData(
): Promise<Partial<IntermediateInteractiveRollData>> {
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);
});