@trudb/tru-common-lib 0.0.290 → 0.0.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1653,10 +1653,11 @@ class TruMatSelectPanel {
1653
1653
  this.renderer = renderer;
1654
1654
  this.select = select;
1655
1655
  this.util = util;
1656
- this.mouseEnterEvent = () => { };
1657
- this.mouseLeaveEvent = () => { };
1658
- this.mouseUpEvent = () => { };
1659
- this.mouseOver = false;
1656
+ this.documentMouseUpEventFn = () => { };
1657
+ this.removeListeners = () => {
1658
+ if (this.documentMouseUpEventFn)
1659
+ this.documentMouseUpEventFn();
1660
+ };
1660
1661
  }
1661
1662
  ngOnInit() {
1662
1663
  this.select.openedChange.subscribe(isOpen => {
@@ -1668,23 +1669,23 @@ class TruMatSelectPanel {
1668
1669
  panelParentElement.style.width = 'auto';
1669
1670
  panelOverlayContainerElement.style.position = 'static';
1670
1671
  panelOverlayBackdropElement.style.display = 'none';
1671
- this.mouseEnterEvent = this.renderer.listen(panelElement, 'mouseover', () => {
1672
- this.mouseOver = true;
1673
- });
1674
- this.mouseLeaveEvent = this.renderer.listen(panelElement, 'mouseout', () => {
1675
- this.mouseOver = false;
1676
- });
1677
- this.mouseUpEvent = this.renderer.listen(document, 'mouseup', () => {
1678
- if (!this.mouseOver) {
1679
- this.mouseEnterEvent();
1680
- this.mouseLeaveEvent();
1681
- this.mouseUpEvent();
1682
- this.select.close();
1672
+ this.documentMouseUpEventFn = this.renderer.listen(document, 'mouseup', (event) => {
1673
+ if (event.target !== this.select.panel.nativeElement && event.button !== 2) {
1674
+ this.removeListeners();
1675
+ setTimeout(() => {
1676
+ this.select.close();
1677
+ });
1683
1678
  }
1684
1679
  });
1685
1680
  }
1681
+ else {
1682
+ this.removeListeners();
1683
+ }
1686
1684
  });
1687
1685
  }
1686
+ ngOnDestroy() {
1687
+ this.removeListeners();
1688
+ }
1688
1689
  }
1689
1690
  TruMatSelectPanel.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruMatSelectPanel, deps: [{ token: i0.Renderer2 }, { token: i1$4.MatSelect }, { token: TruUtil }], target: i0.ɵɵFactoryTarget.Directive });
1690
1691
  TruMatSelectPanel.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: TruMatSelectPanel, selector: "[tru-mat-select-panel]", ngImport: i0 });