Skip to content

Commit

Permalink
* popover: set command proxy to popover element.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Oct 8, 2024
1 parent dd027cf commit 9be163d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/popover/src/vanilla/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class Popover<O extends PopoverOptions = PopoverOptions, E extends Compon
this._zIndex = Popover.Z_INDEX++;
this._shown = true;
this.render();
SHOWN_POPOVERS.set(this.gid, this);
SHOWN_POPOVERS.set(this.gid, this as Popover);
onShow?.call(this);
this.emit('show');

Expand All @@ -229,8 +229,11 @@ export class Popover<O extends PopoverOptions = PopoverOptions, E extends Compon
});
}

if (!this._virtual && elementShowClass) {
$(this._triggerElement as HTMLElement).addClass(elementShowClass);
if (!this._virtual) {
$target.attr('zui-command-proxy', '').data('zui.commandProxy', this._triggerElement);
if (elementShowClass) {
$(this._triggerElement as HTMLElement).addClass(elementShowClass);
}
}

this._resetTimer(() => {
Expand Down Expand Up @@ -262,8 +265,11 @@ export class Popover<O extends PopoverOptions = PopoverOptions, E extends Compon
$target.off(this.namespace);
}

if (!this._virtual && elementShowClass) {
$(this._triggerElement as HTMLElement).removeClass(elementShowClass).removeAttr('data-pop-placement');
if (!this._virtual) {
$target.removeAttr('zui-command-proxy').removeData('zui.commandProxy');
if (elementShowClass) {
$target.removeClass(elementShowClass).removeAttr('data-pop-placement');
}
}

if (hideNewOnHide) {
Expand Down

0 comments on commit 9be163d

Please sign in to comment.