Skip to content

Commit 5170ca7

Browse files
committed
Refactor dialog button callback to use DialogV2 type and update prompt method
1 parent 66438a4 commit 5170ca7

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

src/ts/ui/nested-effect-selection-dialog.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function getNestedEffectSelection(
2323
},
2424
);
2525

26-
const choice = (await DialogV2.wait({
26+
const choice = (await DialogV2.prompt({
2727
id: "nested-effect-selection-dialog",
2828
window: {
2929
title: effectData.name,
@@ -36,24 +36,18 @@ async function getNestedEffectSelection(
3636
return null;
3737
},
3838
content,
39-
buttons: [
40-
{
41-
action: "ok",
42-
label: "ConvenientEffects.SelectEffect",
43-
icon: "fa-solid fa-check",
44-
callback: async (
45-
_event: PointerEvent | SubmitEvent,
46-
_button: HTMLButtonElement,
47-
dialog: HTMLDialogElement,
48-
) => {
49-
const htmlChoice = $(dialog)
50-
.find('select[name="effect-choice"]')
51-
.val();
52-
return htmlChoice;
53-
},
54-
default: true,
39+
ok: {
40+
action: "ok",
41+
label: "ConvenientEffects.SelectEffect",
42+
icon: "fa-solid fa-check",
43+
callback: async (_event, _button, dialog) => {
44+
const htmlChoice = $(dialog.element)
45+
.find('select[name="effect-choice"]')
46+
.val();
47+
return htmlChoice;
5548
},
56-
],
49+
default: true,
50+
},
5751
})) as string | undefined;
5852

5953
return nestedEffects.find((nestedEffect) => nestedEffect.name === choice);

types/foundry/client-esm/applications/api/dialog.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,15 @@ export interface DialogV2WaitOptions {
152152
export type DialogV2ButtonCallback = (
153153
event: PointerEvent | SubmitEvent,
154154
button: HTMLButtonElement,
155-
dialog: HTMLDialogElement,
155+
dialog: DialogV2,
156156
) => Promise<unknown>;
157157

158158
/**
159159
* A dialog render handler method.
160160
* @param event The render event.
161161
* @param dialog The dialog element.
162162
*/
163-
export type DialogV2RenderCallback = (
164-
event: Event,
165-
dialog: HTMLDialogElement,
166-
) => void;
163+
export type DialogV2RenderCallback = (event: Event, dialog: DialogV2) => void;
167164

168165
/**
169166
* @param event The close event

0 commit comments

Comments
 (0)