@itwin/itwinui-react 3.17.2 → 3.17.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.
package/DEV-esm/styles.js CHANGED
@@ -1,4 +1,4 @@
1
- const t = '3.17.2';
1
+ const t = '3.17.3';
2
2
  const u = new Proxy(
3
3
  {},
4
4
  {
@@ -48,3 +48,13 @@ export type DropdownMenuProps = {
48
48
  * </DropdownMenu>
49
49
  */
50
50
  export declare const DropdownMenu: PolymorphicForwardRefComponent<"div", DropdownMenuProps>;
51
+ export declare const DropdownMenuContext: React.Context<{
52
+ close: () => void;
53
+ } | undefined>;
54
+ /**
55
+ * @private
56
+ * Wraps around a `DropdownMenu`.
57
+ *
58
+ * If `true`, closes the `DropdownMenu` when any descendant `MenuItem` is clicked.
59
+ */
60
+ export declare const DropdownMenuCloseOnClickContext: React.Context<boolean | undefined>;
@@ -2,11 +2,23 @@
2
2
  Object.defineProperty(exports, '__esModule', {
3
3
  value: true,
4
4
  });
5
- Object.defineProperty(exports, 'DropdownMenu', {
6
- enumerable: true,
7
- get: function () {
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name],
10
+ });
11
+ }
12
+ _export(exports, {
13
+ DropdownMenu: function () {
8
14
  return DropdownMenu;
9
15
  },
16
+ DropdownMenuCloseOnClickContext: function () {
17
+ return DropdownMenuCloseOnClickContext;
18
+ },
19
+ DropdownMenuContext: function () {
20
+ return DropdownMenuContext;
21
+ },
10
22
  });
11
23
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
24
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
@@ -41,34 +53,50 @@ const DropdownMenuContent = _react.forwardRef((props, forwardedRef) => {
41
53
  visibleProp,
42
54
  onVisibleChange,
43
55
  );
56
+ let close = _react.useCallback(() => {
57
+ setVisible(false);
58
+ }, [setVisible]);
44
59
  let menuContent = _react.useMemo(() => {
45
- if ('function' == typeof menuItems)
46
- return menuItems(() => setVisible(false));
60
+ if ('function' == typeof menuItems) return menuItems(close);
47
61
  return menuItems;
48
- }, [menuItems, setVisible]);
62
+ }, [close, menuItems]);
63
+ let dropdownMenuContextValue = _react.useMemo(
64
+ () => ({
65
+ close,
66
+ }),
67
+ [close],
68
+ );
49
69
  return _react.createElement(
50
- _Menu.Menu,
70
+ DropdownMenuContext.Provider,
51
71
  {
52
- trigger: children,
53
- onKeyDown: (0, _index.mergeEventHandlers)(props.onKeyDown, (e) => {
54
- if (e.defaultPrevented) return;
55
- if ('Tab' === e.key) setVisible(false);
56
- }),
57
- role: role,
58
- ref: forwardedRef,
59
- portal: portal,
60
- popoverProps: _react.useMemo(
61
- () => ({
62
- placement,
63
- matchWidth,
64
- visible,
65
- onVisibleChange: setVisible,
66
- middleware,
67
- }),
68
- [matchWidth, middleware, placement, setVisible, visible],
69
- ),
70
- ...rest,
72
+ value: dropdownMenuContextValue,
71
73
  },
72
- menuContent,
74
+ _react.createElement(
75
+ _Menu.Menu,
76
+ {
77
+ trigger: children,
78
+ onKeyDown: (0, _index.mergeEventHandlers)(props.onKeyDown, (e) => {
79
+ if (e.defaultPrevented) return;
80
+ if ('Tab' === e.key) setVisible(false);
81
+ }),
82
+ role: role,
83
+ ref: forwardedRef,
84
+ portal: portal,
85
+ popoverProps: _react.useMemo(
86
+ () => ({
87
+ placement,
88
+ matchWidth,
89
+ visible,
90
+ onVisibleChange: setVisible,
91
+ middleware,
92
+ }),
93
+ [matchWidth, middleware, placement, setVisible, visible],
94
+ ),
95
+ ...rest,
96
+ },
97
+ menuContent,
98
+ ),
73
99
  );
74
100
  });
101
+ const DropdownMenuContext = _react.createContext(void 0);
102
+ const DropdownMenuCloseOnClickContext = _react.createContext(void 0);
@@ -28,7 +28,12 @@ type MenuProps = {
28
28
  listNavigation?: Partial<UseListNavigationProps>;
29
29
  };
30
30
  };
31
- } & Pick<PortalProps, 'portal'>;
31
+ /**
32
+ * If not passed, uses the `portal` from its parent `Menu`.
33
+ * @see {@link PortalProps.portal} for docs on the prop.
34
+ */
35
+ portal?: PortalProps['portal'];
36
+ };
32
37
  /**
33
38
  * @private
34
39
  *
@@ -92,4 +97,7 @@ export declare const MenuContext: React.Context<{
92
97
  popoverGetItemProps: PopoverGetItemProps;
93
98
  focusableElements: HTMLElement[];
94
99
  } | undefined>;
100
+ export declare const MenuPortalContext: React.Context<boolean | {
101
+ to: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);
102
+ } | undefined>;
95
103
  export {};
@@ -16,6 +16,9 @@ _export(exports, {
16
16
  MenuContext: function () {
17
17
  return MenuContext;
18
18
  },
19
+ MenuPortalContext: function () {
20
+ return MenuPortalContext;
21
+ },
19
22
  });
20
23
  const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
21
24
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
@@ -31,11 +34,13 @@ const Menu = _react.forwardRef((props, ref) => {
31
34
  className,
32
35
  trigger,
33
36
  positionReference,
34
- portal = true,
37
+ portal: portalProp,
35
38
  popoverProps: popoverPropsProp,
36
39
  children,
37
40
  ...rest
38
41
  } = props;
42
+ let menuPortalContext = _react.useContext(MenuPortalContext);
43
+ let portal = portalProp ?? menuPortalContext;
39
44
  let tree = (0, _react1.useFloatingTree)();
40
45
  let nodeId = (0, _react1.useFloatingNodeId)();
41
46
  let parentId = (0, _react1.useFloatingParentNodeId)();
@@ -134,35 +139,39 @@ const Menu = _react.forwardRef((props, ref) => {
134
139
  () => void 0,
135
140
  () => void 0,
136
141
  );
137
- let popoverGetItemProps = ({ focusableItemIndex, userProps }) =>
138
- getItemProps({
139
- ...userProps,
140
- tabIndex:
141
- null != activeIndex &&
142
- activeIndex >= 0 &&
143
- null != focusableItemIndex &&
144
- focusableItemIndex >= 0 &&
145
- activeIndex === focusableItemIndex
146
- ? 0
147
- : -1,
148
- onFocus: (0, _index.mergeEventHandlers)(userProps?.onFocus, () => {
149
- queueMicrotask(() => {
150
- setHasFocusedNodeInSubmenu(true);
151
- });
152
- tree?.events.emit('onNodeFocused', {
153
- nodeId: nodeId,
154
- parentId: parentId,
155
- });
142
+ let popoverGetItemProps = _react.useCallback(
143
+ ({ focusableItemIndex, userProps }) =>
144
+ getItemProps({
145
+ ...userProps,
146
+ tabIndex:
147
+ null != activeIndex &&
148
+ activeIndex >= 0 &&
149
+ null != focusableItemIndex &&
150
+ focusableItemIndex >= 0 &&
151
+ activeIndex === focusableItemIndex
152
+ ? 0
153
+ : -1,
154
+ onFocus: (0, _index.mergeEventHandlers)(userProps?.onFocus, () => {
155
+ queueMicrotask(() => {
156
+ setHasFocusedNodeInSubmenu(true);
157
+ });
158
+ tree?.events.emit('onNodeFocused', {
159
+ nodeId: nodeId,
160
+ parentId: parentId,
161
+ });
162
+ }),
163
+ onMouseEnter: (0, _index.mergeEventHandlers)(
164
+ userProps?.onMouseEnter,
165
+ (event) => {
166
+ if (null != focusableItemIndex && focusableItemIndex >= 0)
167
+ setActiveIndex(focusableItemIndex);
168
+ if (event.target === event.currentTarget)
169
+ event.currentTarget.focus();
170
+ },
171
+ ),
156
172
  }),
157
- onMouseEnter: (0, _index.mergeEventHandlers)(
158
- userProps?.onMouseEnter,
159
- (event) => {
160
- if (null != focusableItemIndex && focusableItemIndex >= 0)
161
- setActiveIndex(focusableItemIndex);
162
- if (event.target === event.currentTarget) event.currentTarget.focus();
163
- },
164
- ),
165
- });
173
+ [activeIndex, getItemProps, nodeId, parentId, tree?.events],
174
+ );
166
175
  let reference = (0, _index.cloneElementWithRef)(trigger, (triggerChild) =>
167
176
  getReferenceProps(
168
177
  popover.getReferenceProps({
@@ -201,28 +210,38 @@ const Menu = _react.forwardRef((props, ref) => {
201
210
  _react.createElement(
202
211
  MenuContext.Provider,
203
212
  {
204
- value: {
205
- popoverGetItemProps,
206
- focusableElements,
207
- },
213
+ value: _react.useMemo(
214
+ () => ({
215
+ popoverGetItemProps,
216
+ focusableElements,
217
+ }),
218
+ [focusableElements, popoverGetItemProps],
219
+ ),
208
220
  },
209
221
  _react.createElement(
210
- _Popover.PopoverOpenContext.Provider,
222
+ MenuPortalContext.Provider,
211
223
  {
212
- value: popover.open,
224
+ value: portal,
213
225
  },
214
- reference,
226
+ _react.createElement(
227
+ _Popover.PopoverOpenContext.Provider,
228
+ {
229
+ value: popover.open,
230
+ },
231
+ reference,
232
+ ),
233
+ null != tree
234
+ ? _react.createElement(
235
+ _react1.FloatingNode,
236
+ {
237
+ id: nodeId,
238
+ },
239
+ floating,
240
+ )
241
+ : floating,
215
242
  ),
216
- null != tree
217
- ? _react.createElement(
218
- _react1.FloatingNode,
219
- {
220
- id: nodeId,
221
- },
222
- floating,
223
- )
224
- : floating,
225
243
  ),
226
244
  );
227
245
  });
228
246
  const MenuContext = _react.createContext(void 0);
247
+ const MenuPortalContext = _react.createContext(void 0);
@@ -17,6 +17,7 @@ const _ListItem = require('../List/ListItem.js');
17
17
  const _classnames = /*#__PURE__*/ _interop_require_default._(
18
18
  require('classnames'),
19
19
  );
20
+ const _DropdownMenu = require('../DropdownMenu/DropdownMenu.js');
20
21
  const MenuItem = _react.forwardRef((props, forwardedRef) => {
21
22
  let {
22
23
  className,
@@ -37,6 +38,10 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
37
38
  } = props;
38
39
  let logWarning = (0, _index.useWarningLogger)();
39
40
  let parentMenu = _react.useContext(_Menu.MenuContext);
41
+ let dropdownMenu = _react.useContext(_DropdownMenu.DropdownMenuContext);
42
+ let shouldCloseMenuOnClick = _react.useContext(
43
+ _DropdownMenu.DropdownMenuCloseOnClickContext,
44
+ );
40
45
  let menuItemRef = _react.useRef(null);
41
46
  let submenuId = (0, _index.useId)();
42
47
  let popoverProps = _react.useMemo(
@@ -55,6 +60,7 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
55
60
  );
56
61
  let onClick = () => {
57
62
  if (disabled) return;
63
+ if (shouldCloseMenuOnClick) dropdownMenu?.close();
58
64
  onClickProp?.(value);
59
65
  };
60
66
  let handlers = {
@@ -196,41 +196,39 @@ const TileMoreOptions = _react.forwardRef((props, forwardedRef) => {
196
196
  let { className, children = [], buttonProps, ...rest } = props;
197
197
  let [isMenuVisible, setIsMenuVisible] = _react.useState(false);
198
198
  return _react.createElement(
199
- _index.Box,
199
+ _DropdownMenu.DropdownMenuCloseOnClickContext.Provider,
200
200
  {
201
- className: (0, _classnames.default)(
202
- 'iui-tile-more-options',
203
- {
204
- 'iui-visible': isMenuVisible,
205
- },
206
- className,
207
- ),
208
- ref: forwardedRef,
209
- ...rest,
201
+ value: true,
210
202
  },
211
203
  _react.createElement(
212
- _DropdownMenu.DropdownMenu,
204
+ _index.Box,
213
205
  {
214
- onVisibleChange: setIsMenuVisible,
215
- menuItems: (close) =>
216
- children?.map((option) =>
217
- _react.cloneElement(option, {
218
- onClick: (value) => {
219
- close();
220
- option.props.onClick?.(value);
221
- },
222
- }),
223
- ),
206
+ className: (0, _classnames.default)(
207
+ 'iui-tile-more-options',
208
+ {
209
+ 'iui-visible': isMenuVisible,
210
+ },
211
+ className,
212
+ ),
213
+ ref: forwardedRef,
214
+ ...rest,
224
215
  },
225
216
  _react.createElement(
226
- _IconButton.IconButton,
217
+ _DropdownMenu.DropdownMenu,
227
218
  {
228
- styleType: 'borderless',
229
- size: 'small',
230
- 'aria-label': 'More options',
231
- ...buttonProps,
219
+ onVisibleChange: setIsMenuVisible,
220
+ menuItems: children,
232
221
  },
233
- _react.createElement(_index.SvgMore, null),
222
+ _react.createElement(
223
+ _IconButton.IconButton,
224
+ {
225
+ styleType: 'borderless',
226
+ size: 'small',
227
+ 'aria-label': 'More options',
228
+ ...buttonProps,
229
+ },
230
+ _react.createElement(_index.SvgMore, null),
231
+ ),
234
232
  ),
235
233
  ),
236
234
  );
package/cjs/styles.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
- const e = '3.17.2';
3
+ const e = '3.17.3';
4
4
  const u = new Proxy(
5
5
  {},
6
6
  {
@@ -48,3 +48,13 @@ export type DropdownMenuProps = {
48
48
  * </DropdownMenu>
49
49
  */
50
50
  export declare const DropdownMenu: PolymorphicForwardRefComponent<"div", DropdownMenuProps>;
51
+ export declare const DropdownMenuContext: React.Context<{
52
+ close: () => void;
53
+ } | undefined>;
54
+ /**
55
+ * @private
56
+ * Wraps around a `DropdownMenu`.
57
+ *
58
+ * If `true`, closes the `DropdownMenu` when any descendant `MenuItem` is clicked.
59
+ */
60
+ export declare const DropdownMenuCloseOnClickContext: React.Context<boolean | undefined>;
@@ -30,34 +30,50 @@ let DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
30
30
  visibleProp,
31
31
  onVisibleChange,
32
32
  );
33
+ let close = React.useCallback(() => {
34
+ setVisible(false);
35
+ }, [setVisible]);
33
36
  let menuContent = React.useMemo(() => {
34
- if ('function' == typeof menuItems)
35
- return menuItems(() => setVisible(false));
37
+ if ('function' == typeof menuItems) return menuItems(close);
36
38
  return menuItems;
37
- }, [menuItems, setVisible]);
39
+ }, [close, menuItems]);
40
+ let dropdownMenuContextValue = React.useMemo(
41
+ () => ({
42
+ close,
43
+ }),
44
+ [close],
45
+ );
38
46
  return React.createElement(
39
- Menu,
47
+ DropdownMenuContext.Provider,
40
48
  {
41
- trigger: children,
42
- onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
43
- if (e.defaultPrevented) return;
44
- if ('Tab' === e.key) setVisible(false);
45
- }),
46
- role: role,
47
- ref: forwardedRef,
48
- portal: portal,
49
- popoverProps: React.useMemo(
50
- () => ({
51
- placement,
52
- matchWidth,
53
- visible,
54
- onVisibleChange: setVisible,
55
- middleware,
56
- }),
57
- [matchWidth, middleware, placement, setVisible, visible],
58
- ),
59
- ...rest,
49
+ value: dropdownMenuContextValue,
60
50
  },
61
- menuContent,
51
+ React.createElement(
52
+ Menu,
53
+ {
54
+ trigger: children,
55
+ onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
56
+ if (e.defaultPrevented) return;
57
+ if ('Tab' === e.key) setVisible(false);
58
+ }),
59
+ role: role,
60
+ ref: forwardedRef,
61
+ portal: portal,
62
+ popoverProps: React.useMemo(
63
+ () => ({
64
+ placement,
65
+ matchWidth,
66
+ visible,
67
+ onVisibleChange: setVisible,
68
+ middleware,
69
+ }),
70
+ [matchWidth, middleware, placement, setVisible, visible],
71
+ ),
72
+ ...rest,
73
+ },
74
+ menuContent,
75
+ ),
62
76
  );
63
77
  });
78
+ export const DropdownMenuContext = React.createContext(void 0);
79
+ export const DropdownMenuCloseOnClickContext = React.createContext(void 0);
@@ -28,7 +28,12 @@ type MenuProps = {
28
28
  listNavigation?: Partial<UseListNavigationProps>;
29
29
  };
30
30
  };
31
- } & Pick<PortalProps, 'portal'>;
31
+ /**
32
+ * If not passed, uses the `portal` from its parent `Menu`.
33
+ * @see {@link PortalProps.portal} for docs on the prop.
34
+ */
35
+ portal?: PortalProps['portal'];
36
+ };
32
37
  /**
33
38
  * @private
34
39
  *
@@ -92,4 +97,7 @@ export declare const MenuContext: React.Context<{
92
97
  popoverGetItemProps: PopoverGetItemProps;
93
98
  focusableElements: HTMLElement[];
94
99
  } | undefined>;
100
+ export declare const MenuPortalContext: React.Context<boolean | {
101
+ to: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);
102
+ } | undefined>;
95
103
  export {};
@@ -25,11 +25,13 @@ export const Menu = React.forwardRef((props, ref) => {
25
25
  className,
26
26
  trigger,
27
27
  positionReference,
28
- portal = true,
28
+ portal: portalProp,
29
29
  popoverProps: popoverPropsProp,
30
30
  children,
31
31
  ...rest
32
32
  } = props;
33
+ let menuPortalContext = React.useContext(MenuPortalContext);
34
+ let portal = portalProp ?? menuPortalContext;
33
35
  let tree = useFloatingTree();
34
36
  let nodeId = useFloatingNodeId();
35
37
  let parentId = useFloatingParentNodeId();
@@ -125,32 +127,35 @@ export const Menu = React.forwardRef((props, ref) => {
125
127
  () => void 0,
126
128
  () => void 0,
127
129
  );
128
- let popoverGetItemProps = ({ focusableItemIndex, userProps }) =>
129
- getItemProps({
130
- ...userProps,
131
- tabIndex:
132
- null != activeIndex &&
133
- activeIndex >= 0 &&
134
- null != focusableItemIndex &&
135
- focusableItemIndex >= 0 &&
136
- activeIndex === focusableItemIndex
137
- ? 0
138
- : -1,
139
- onFocus: mergeEventHandlers(userProps?.onFocus, () => {
140
- queueMicrotask(() => {
141
- setHasFocusedNodeInSubmenu(true);
142
- });
143
- tree?.events.emit('onNodeFocused', {
144
- nodeId: nodeId,
145
- parentId: parentId,
146
- });
130
+ let popoverGetItemProps = React.useCallback(
131
+ ({ focusableItemIndex, userProps }) =>
132
+ getItemProps({
133
+ ...userProps,
134
+ tabIndex:
135
+ null != activeIndex &&
136
+ activeIndex >= 0 &&
137
+ null != focusableItemIndex &&
138
+ focusableItemIndex >= 0 &&
139
+ activeIndex === focusableItemIndex
140
+ ? 0
141
+ : -1,
142
+ onFocus: mergeEventHandlers(userProps?.onFocus, () => {
143
+ queueMicrotask(() => {
144
+ setHasFocusedNodeInSubmenu(true);
145
+ });
146
+ tree?.events.emit('onNodeFocused', {
147
+ nodeId: nodeId,
148
+ parentId: parentId,
149
+ });
150
+ }),
151
+ onMouseEnter: mergeEventHandlers(userProps?.onMouseEnter, (event) => {
152
+ if (null != focusableItemIndex && focusableItemIndex >= 0)
153
+ setActiveIndex(focusableItemIndex);
154
+ if (event.target === event.currentTarget) event.currentTarget.focus();
155
+ }),
147
156
  }),
148
- onMouseEnter: mergeEventHandlers(userProps?.onMouseEnter, (event) => {
149
- if (null != focusableItemIndex && focusableItemIndex >= 0)
150
- setActiveIndex(focusableItemIndex);
151
- if (event.target === event.currentTarget) event.currentTarget.focus();
152
- }),
153
- });
157
+ [activeIndex, getItemProps, nodeId, parentId, tree?.events],
158
+ );
154
159
  let reference = cloneElementWithRef(trigger, (triggerChild) =>
155
160
  getReferenceProps(
156
161
  popover.getReferenceProps({
@@ -189,28 +194,38 @@ export const Menu = React.forwardRef((props, ref) => {
189
194
  React.createElement(
190
195
  MenuContext.Provider,
191
196
  {
192
- value: {
193
- popoverGetItemProps,
194
- focusableElements,
195
- },
197
+ value: React.useMemo(
198
+ () => ({
199
+ popoverGetItemProps,
200
+ focusableElements,
201
+ }),
202
+ [focusableElements, popoverGetItemProps],
203
+ ),
196
204
  },
197
205
  React.createElement(
198
- PopoverOpenContext.Provider,
206
+ MenuPortalContext.Provider,
199
207
  {
200
- value: popover.open,
208
+ value: portal,
201
209
  },
202
- reference,
210
+ React.createElement(
211
+ PopoverOpenContext.Provider,
212
+ {
213
+ value: popover.open,
214
+ },
215
+ reference,
216
+ ),
217
+ null != tree
218
+ ? React.createElement(
219
+ FloatingNode,
220
+ {
221
+ id: nodeId,
222
+ },
223
+ floating,
224
+ )
225
+ : floating,
203
226
  ),
204
- null != tree
205
- ? React.createElement(
206
- FloatingNode,
207
- {
208
- id: nodeId,
209
- },
210
- floating,
211
- )
212
- : floating,
213
227
  ),
214
228
  );
215
229
  });
216
230
  export const MenuContext = React.createContext(void 0);
231
+ export const MenuPortalContext = React.createContext(void 0);
@@ -8,6 +8,10 @@ import {
8
8
  import { Menu, MenuContext } from './Menu.js';
9
9
  import { ListItem } from '../List/ListItem.js';
10
10
  import cx from 'classnames';
11
+ import {
12
+ DropdownMenuCloseOnClickContext,
13
+ DropdownMenuContext,
14
+ } from '../DropdownMenu/DropdownMenu.js';
11
15
  export const MenuItem = React.forwardRef((props, forwardedRef) => {
12
16
  let {
13
17
  className,
@@ -28,6 +32,10 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
28
32
  } = props;
29
33
  let logWarning = useWarningLogger();
30
34
  let parentMenu = React.useContext(MenuContext);
35
+ let dropdownMenu = React.useContext(DropdownMenuContext);
36
+ let shouldCloseMenuOnClick = React.useContext(
37
+ DropdownMenuCloseOnClickContext,
38
+ );
31
39
  let menuItemRef = React.useRef(null);
32
40
  let submenuId = useId();
33
41
  let popoverProps = React.useMemo(
@@ -46,6 +54,7 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
46
54
  );
47
55
  let onClick = () => {
48
56
  if (disabled) return;
57
+ if (shouldCloseMenuOnClick) dropdownMenu?.close();
49
58
  onClickProp?.(value);
50
59
  };
51
60
  let handlers = {