@dotglitch/ngx-common 1.0.7 → 1.0.8

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.
@@ -703,7 +703,7 @@ class MenuDirective {
703
703
  el.onclick = this.openMenu.bind(this);
704
704
  el.addEventListener('contextmenu', (e) => {
705
705
  e.preventDefault();
706
- this.openMenu(e);
706
+ this.openMenu(e, this.ctxMenuItems);
707
707
  });
708
708
  }
709
709
  if (!this.config?.trigger) {
@@ -715,7 +715,7 @@ class MenuDirective {
715
715
  if (t == "contextmenu") {
716
716
  el.addEventListener(t, (e) => {
717
717
  e.preventDefault();
718
- this.openMenu(e);
718
+ this.openMenu(e, this.ctxMenuItems);
719
719
  });
720
720
  }
721
721
  else {
@@ -724,10 +724,11 @@ class MenuDirective {
724
724
  });
725
725
  }
726
726
  }
727
- async openMenu(evt) {
727
+ async openMenu(evt, items = this.menuItems) {
728
728
  const el = this.viewContainer.element.nativeElement;
729
729
  el.classList.add("ngx-menu-open");
730
- return openMenu(this.dialog, this.menuItems, this.data, evt, this.config, el)
730
+ const isCtxEvent = evt.button == 2;
731
+ return openMenu(this.dialog, items, this.data, evt, this.config, isCtxEvent ? null : el)
731
732
  .then((...res) => {
732
733
  el.classList.remove("ngx-menu-open");
733
734
  return res;
@@ -778,12 +779,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
778
779
  }] } });
779
780
  // Helper to open the menu without using the directive.
780
781
  const openMenu = async (dialog, menuItems, data, evt, config = {}, el) => {
782
+ // console.log({ dialog, menuItems, data, evt, config, el });
781
783
  evt.preventDefault();
782
784
  evt.stopPropagation();
783
- const cords = getPosition(el || evt, config, await calcMenuItemBounds(menuItems, data));
784
- const specificId = crypto.randomUUID();
785
+ // Apply defaults.
785
786
  if (!config.alignment)
786
787
  config.alignment = "start";
788
+ const cords = getPosition(el || evt, config, await calcMenuItemBounds(menuItems, data));
789
+ const specificId = crypto.randomUUID();
787
790
  return new Promise(res => {
788
791
  dialog.open(MenuComponent, {
789
792
  data: {