mirror of
https://github.com/codex-team/editor.js
synced 2024-05-25 01:52:26 +02:00
propagate click event to popover item activation callback
This commit is contained in:
parent
238c909016
commit
4d776680af
|
@ -103,15 +103,16 @@ export class PopoverItemDefault extends PopoverItem {
|
|||
|
||||
/**
|
||||
* Called on popover item click
|
||||
* @param event - click event
|
||||
*/
|
||||
public handleClick(): void {
|
||||
public handleClick(event: Event): void {
|
||||
if (this.isConfirmationStateEnabled && this.confirmationState !== null) {
|
||||
this.activateOrEnableConfirmationMode(this.confirmationState);
|
||||
this.activateOrEnableConfirmationMode(this.confirmationState, event);
|
||||
|
||||
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
|
||||
*
|
||||
* @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) {
|
||||
try {
|
||||
item.onActivate?.(item);
|
||||
item.onActivate?.(item, event);
|
||||
this.disableConfirmationMode();
|
||||
} catch {
|
||||
this.animateError();
|
||||
|
|
|
@ -261,7 +261,7 @@ export abstract class PopoverAbstract<Nodes extends PopoverNodes = PopoverNodes>
|
|||
/** Cleanup other items state */
|
||||
this.itemsInteractive.filter(x => x !== item).forEach(x => x.reset());
|
||||
|
||||
item.handleClick();
|
||||
item.handleClick(event);
|
||||
|
||||
this.toggleItemActivenessIfNeeded(item);
|
||||
|
||||
|
|
Loading…
Reference in a new issue