Skip to content

Commit

Permalink
Use core document-deletion dialog when deleting embedded items (found…
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam committed Jan 24, 2024
1 parent 105fcc0 commit 487e48b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/module/actor/sheet/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,8 @@ abstract class ActorSheetPF2e<TActor extends ActorPF2e> extends ActorSheet<TActo
await this.actor.updateEmbeddedDocuments("Item", sortingUpdates);
}

protected async deleteItem(item: ItemPF2e, event?: MouseEvent): Promise<void> {
const result =
event?.ctrlKey ||
(await Dialog.confirm({
title: game.i18n.localize("PF2E.DeleteItemTitle"),
content: `<p>${game.i18n.format("PF2E.DeleteQuestion", { name: `"${item.name}"` })}</p>`,
}));
if (result) await item.delete();
protected deleteItem<TItem extends ItemPF2e>(item: TItem, event?: MouseEvent): Promise<TItem | undefined> {
return event?.ctrlKey ? item.delete() : item.deleteDialog();
}

#onClickBrowseAbilities(anchor: HTMLElement): void {
Expand Down
2 changes: 1 addition & 1 deletion types/foundry/client/data/documents/client-base-mixes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5464,7 +5464,7 @@ export class ClientBaseItem<
* @param [options] Positioning and sizing options for the resulting dialog
* @return A Promise which resolves to the deleted Document
*/
deleteDialog(options?: ConfirmDialogParameters): Promise<this>;
deleteDialog(options?: ConfirmDialogParameters): Promise<this | undefined>;

/**
* Export document data to a JSON file which can be saved by the client and later imported into a different session.
Expand Down

0 comments on commit 487e48b

Please sign in to comment.