Et2Select: All selectboxes now stop scroll event from bubbling to prevent parent (sidemenu) from scrolling too

This commit is contained in:
nathan 2022-09-23 10:54:02 -06:00
parent 171c9c02cb
commit 086d92e957
2 changed files with 14 additions and 24 deletions

View File

@ -163,12 +163,15 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
this._triggerChange = this._triggerChange.bind(this); this._triggerChange = this._triggerChange.bind(this);
this._doResize = this._doResize.bind(this); this._doResize = this._doResize.bind(this);
this._handleMouseWheel = this._handleMouseWheel.bind(this);
} }
connectedCallback() connectedCallback()
{ {
super.connectedCallback(); super.connectedCallback();
this.addEventListener("mousewheel", this._handleMouseWheel);
this.updateComplete.then(() => this.updateComplete.then(() =>
{ {
this.addEventListener("sl-change", this._triggerChange); this.addEventListener("sl-change", this._triggerChange);
@ -180,6 +183,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
{ {
super.disconnectedCallback(); super.disconnectedCallback();
this.removeEventListener("mousewheel", this._handleMouseWheel);
this.removeEventListener("sl-clear", this._triggerChange) this.removeEventListener("sl-clear", this._triggerChange)
this.removeEventListener("sl-change", this._triggerChange); this.removeEventListener("sl-change", this._triggerChange);
this.removeEventListener("sl-after-show", this._doResize); this.removeEventListener("sl-after-show", this._doResize);
@ -210,6 +214,16 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
this.menu.style.width = ""; this.menu.style.width = "";
} }
/**
* Stop scroll from bubbling so the sidemenu doesn't scroll too
*
* @param {MouseEvent} e
*/
private _handleMouseWheel(e : MouseEvent)
{
e.stopPropagation();
}
/** /**
* Get the node where we're putting the selection options * Get the node where we're putting the selection options
* *

View File

@ -38,20 +38,6 @@ export class CalendarOwner extends Et2Select
super(...args); super(...args);
this.searchUrl = "calendar_owner_etemplate_widget::ajax_search"; this.searchUrl = "calendar_owner_etemplate_widget::ajax_search";
this.multiple = true; this.multiple = true;
this._handleMouseWheel = this._handleMouseWheel.bind(this);
}
_bindListeners()
{
super._bindListeners();
this.addEventListener("mousewheel", this._handleMouseWheel);
}
_unbindListeners()
{
this.removeEventListener("mousewheel", this._handleMouseWheel);
} }
/** /**
@ -106,16 +92,6 @@ export class CalendarOwner extends Et2Select
}); });
} }
/**
* Stop scroll from bubbling so the sidemenu doesn't scroll too
*
* @param {MouseEvent} e
*/
_handleMouseWheel(e : MouseEvent)
{
e.stopPropagation();
}
/** /**
* Check if a free entry value is acceptable. * Check if a free entry value is acceptable.
* We only check the free entry, since value can be mixed. * We only check the free entry, since value can be mixed.