@momentum-design/components 0.85.1 → 0.85.3

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.
@@ -62,6 +62,8 @@ declare class MenuPopover extends Popover {
62
62
  * This method is used to ensure that when a menu item is clicked,
63
63
  * all other open popovers are closed, maintaining a clean user interface.
64
64
  * It iterates through the `popoverStack` and hides each popover until the stack is empty.
65
+ *
66
+ * @param until - The popover to close until.
65
67
  */
66
68
  private closeAllMenuPopovers;
67
69
  /**
@@ -68,6 +68,12 @@ class MenuPopover extends Popover {
68
68
  this.onOutsidePopoverClick = (event) => {
69
69
  if (popoverStack.peek() !== this)
70
70
  return;
71
+ const popoverOfTarget = event.target.closest(MENU_POPOVER);
72
+ // If the click occurred on a submenu, close all popovers until the submenu
73
+ if (popoverOfTarget && popoverStack.has(popoverOfTarget)) {
74
+ this.closeAllMenuPopovers(popoverOfTarget);
75
+ return;
76
+ }
71
77
  let insidePopoverClick = false;
72
78
  const path = event.composedPath();
73
79
  insidePopoverClick = this.contains(event.target) || path.includes(this.triggerElement);
@@ -146,13 +152,18 @@ class MenuPopover extends Popover {
146
152
  * This method is used to ensure that when a menu item is clicked,
147
153
  * all other open popovers are closed, maintaining a clean user interface.
148
154
  * It iterates through the `popoverStack` and hides each popover until the stack is empty.
155
+ *
156
+ * @param until - The popover to close until.
149
157
  */
150
- closeAllMenuPopovers() {
151
- while (popoverStack.peek()) {
158
+ closeAllMenuPopovers(until) {
159
+ while (popoverStack.peek() !== until) {
152
160
  const popover = popoverStack.pop();
153
161
  if (popover) {
154
162
  popover.hidePopover();
155
163
  }
164
+ else {
165
+ break;
166
+ }
156
167
  }
157
168
  }
158
169
  /**
@@ -36,6 +36,13 @@ declare class PopoverStack {
36
36
  * @param popover - Popover instance
37
37
  */
38
38
  remove(popover: Popover): void;
39
+ /**
40
+ * Checks if the stack has a specific popover
41
+ *
42
+ * @param popover - Popover instance
43
+ * @returns True if the stack has the popover, false otherwise
44
+ */
45
+ has(popover: Popover): boolean;
39
46
  /**
40
47
  * Clears the stack
41
48
  */
@@ -45,6 +45,15 @@ class PopoverStack {
45
45
  remove(popover) {
46
46
  this.stack = this.stack.filter(item => item !== popover);
47
47
  }
48
+ /**
49
+ * Checks if the stack has a specific popover
50
+ *
51
+ * @param popover - Popover instance
52
+ * @returns True if the stack has the popover, false otherwise
53
+ */
54
+ has(popover) {
55
+ return this.stack.includes(popover);
56
+ }
48
57
  /**
49
58
  * Clears the stack
50
59
  */