propagate click event to popover item activation callback

This commit is contained in:
Maurits 2024-05-01 11:16:10 +02:00
parent 238c909016
commit 4d776680af
2 changed files with 8 additions and 6 deletions

View file

@ -103,15 +103,16 @@ export class PopoverItemDefault extends PopoverItem {
/** /**
* Called on popover item click * Called on popover item click
* @param event - click event
*/ */
public handleClick(): void { public handleClick(event: Event): void {
if (this.isConfirmationStateEnabled && this.confirmationState !== null) { if (this.isConfirmationStateEnabled && this.confirmationState !== null) {
this.activateOrEnableConfirmationMode(this.confirmationState); this.activateOrEnableConfirmationMode(this.confirmationState, event);
return; return;
} }
this.activateOrEnableConfirmationMode(this.params); this.activateOrEnableConfirmationMode(this.params, event);
} }
/** /**
@ -281,11 +282,12 @@ export class PopoverItemDefault extends PopoverItem {
* Executes item's onActivate callback if the item has no confirmation configured * Executes item's onActivate callback if the item has no confirmation configured
* *
* @param item - item to activate or bring to confirmation mode * @param item - item to activate or bring to confirmation mode
* @param event - pointer event that triggered item activation
*/ */
private activateOrEnableConfirmationMode(item: PopoverItemDefaultParams): void { private activateOrEnableConfirmationMode(item: PopoverItemDefaultParams, event?: PointerEvent): void {
if (item.confirmation === undefined) { if (item.confirmation === undefined) {
try { try {
item.onActivate?.(item); item.onActivate?.(item, event);
this.disableConfirmationMode(); this.disableConfirmationMode();
} catch { } catch {
this.animateError(); this.animateError();

View file

@ -261,7 +261,7 @@ export abstract class PopoverAbstract<Nodes extends PopoverNodes = PopoverNodes>
/** Cleanup other items state */ /** Cleanup other items state */
this.itemsInteractive.filter(x => x !== item).forEach(x => x.reset()); this.itemsInteractive.filter(x => x !== item).forEach(x => x.reset());
item.handleClick(); item.handleClick(event);
this.toggleItemActivenessIfNeeded(item); this.toggleItemActivenessIfNeeded(item);