Skip to content

Commit

Permalink
fix: fix tracking click event for Popup (rename the method and argume…
Browse files Browse the repository at this point in the history
…nts)
  • Loading branch information
yadamskaya committed Jan 19, 2021
1 parent 2c3bff0 commit 8abd6e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/modules/esl-base-popup/core/esl-base-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ESLBasePopup extends ESLBaseElement {
@attr({name: 'close-on'}) public closeTrigger: string;

@boolAttr() public closeOnEsc: boolean;
@boolAttr() public closeOnBodyClick: boolean;
@boolAttr() public closeOnOutsideAction: boolean;

@jsonAttr<PopupActionParams>({defaultValue: {silent: true, force: true, initiator: 'init'}})
public initialParams: PopupActionParams;
Expand Down Expand Up @@ -91,16 +91,16 @@ export class ESLBasePopup extends ESLBaseElement {
protected unbindEvents() {
this.removeEventListener('click', this._onClick);
this.removeEventListener('keydown', this._onKeyboardEvent);
this.bindBodyClickTracking(false);
this.bindOutsideEventTracking(false);
this.bindHoverStateTracking(false);
}

protected bindBodyClickTracking(track: boolean) {
document.body.removeEventListener('mousedown', this._onBodyClick);
document.body.removeEventListener('touchstart', this._onBodyClick);
protected bindOutsideEventTracking(track: boolean) {
document.body.removeEventListener('mousedown', this._onOutsideAction);
document.body.removeEventListener('touchstart', this._onOutsideAction);
if (track) {
document.body.addEventListener('mousedown', this._onBodyClick, true);
document.body.addEventListener('touchstart', this._onBodyClick, true);
document.body.addEventListener('mousedown', this._onOutsideAction, true);
document.body.addEventListener('touchstart', this._onOutsideAction, true);
}
}
protected bindHoverStateTracking(track: boolean) {
Expand Down Expand Up @@ -134,7 +134,7 @@ export class ESLBasePopup extends ESLBaseElement {
params = this.mergeDefaultParams(params);
this.group.activate(this, params);
this.planShowTask(params);
this.bindBodyClickTracking(this.closeOnBodyClick);
this.bindOutsideEventTracking(this.closeOnOutsideAction);
this.bindHoverStateTracking(!!params.trackHover);
return this;
}
Expand All @@ -153,7 +153,7 @@ export class ESLBasePopup extends ESLBaseElement {
public hide(params?: PopupActionParams) {
params = this.mergeDefaultParams(params);
this.planHideTask(params);
this.bindBodyClickTracking(false);
this.bindOutsideEventTracking(false);
this.bindHoverStateTracking(!!params.trackHover);
return this;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ export class ESLBasePopup extends ESLBaseElement {
}
}
@bind
protected _onBodyClick(e: MouseEvent) {
protected _onOutsideAction(e: MouseEvent) {
const target = e.target as HTMLElement;
if (!this.contains(target)) {
this.hide({initiator: 'bodyclick', trigger: target});
Expand Down
4 changes: 2 additions & 2 deletions src/modules/esl-trigger/core/esl-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ export class ESLTrigger extends ESLBaseElement {

@bind
protected _onShowEvent(e: Event) {
(e.type === 'click' && this.popup.closeOnBodyClick) && e.stopPropagation();
(e.type === 'click' && this.popup.closeOnOutsideAction) && e.stopPropagation();
this.popup.show({
trigger: this,
delay: this.showDelayValue
});
}
@bind
protected _onHideEvent(e: Event) {
(e.type === 'click' && this.popup.closeOnBodyClick) && e.stopPropagation();
(e.type === 'click' && this.popup.closeOnOutsideAction) && e.stopPropagation();
this.popup.hide({
trigger: this,
delay: this.hideDelayValue,
Expand Down

0 comments on commit 8abd6e5

Please sign in to comment.