@itwin/itwinui-react 3.17.2 → 3.17.4

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/DEV-cjs/core/ComboBox/ComboBox.js +17 -21
  3. package/DEV-cjs/core/ComboBox/ComboBoxMenu.js +6 -2
  4. package/DEV-cjs/core/DropdownMenu/DropdownMenu.js +55 -27
  5. package/DEV-cjs/core/Menu/Menu.js +64 -45
  6. package/DEV-cjs/core/Menu/MenuItem.js +6 -0
  7. package/DEV-cjs/core/Tabs/Tabs.js +7 -2
  8. package/DEV-cjs/core/Tile/Tile.js +25 -27
  9. package/DEV-cjs/core/Tree/Tree.js +25 -17
  10. package/DEV-cjs/styles.js +1 -1
  11. package/DEV-esm/core/ComboBox/ComboBox.js +17 -21
  12. package/DEV-esm/core/ComboBox/ComboBoxMenu.js +6 -2
  13. package/DEV-esm/core/DropdownMenu/DropdownMenu.js +40 -24
  14. package/DEV-esm/core/Menu/Menu.js +57 -42
  15. package/DEV-esm/core/Menu/MenuItem.js +9 -0
  16. package/DEV-esm/core/Tabs/Tabs.js +5 -2
  17. package/DEV-esm/core/Tile/Tile.js +29 -28
  18. package/DEV-esm/core/Tree/Tree.js +25 -17
  19. package/DEV-esm/styles.js +1 -1
  20. package/cjs/core/ComboBox/ComboBox.js +17 -21
  21. package/cjs/core/ComboBox/ComboBoxMenu.js +6 -2
  22. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +10 -0
  23. package/cjs/core/DropdownMenu/DropdownMenu.js +55 -27
  24. package/cjs/core/Menu/Menu.d.ts +9 -1
  25. package/cjs/core/Menu/Menu.js +64 -45
  26. package/cjs/core/Menu/MenuItem.js +6 -0
  27. package/cjs/core/Tabs/Tabs.js +7 -2
  28. package/cjs/core/Tile/Tile.js +25 -27
  29. package/cjs/core/Tree/Tree.js +25 -17
  30. package/cjs/styles.js +1 -1
  31. package/esm/core/ComboBox/ComboBox.js +17 -21
  32. package/esm/core/ComboBox/ComboBoxMenu.js +6 -2
  33. package/esm/core/DropdownMenu/DropdownMenu.d.ts +10 -0
  34. package/esm/core/DropdownMenu/DropdownMenu.js +40 -24
  35. package/esm/core/Menu/Menu.d.ts +9 -1
  36. package/esm/core/Menu/Menu.js +57 -42
  37. package/esm/core/Menu/MenuItem.js +9 -0
  38. package/esm/core/Tabs/Tabs.js +5 -2
  39. package/esm/core/Tile/Tile.js +29 -28
  40. package/esm/core/Tree/Tree.js +25 -17
  41. package/esm/styles.js +1 -1
  42. package/package.json +2 -2
  43. package/styles.css +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.17.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2473](https://github.com/iTwin/iTwinUI/pull/2473): Fixed scrolling on touch devices when using the `enableVirtualization` prop in `Tree` and `ComboBox`.
8
+ - [#2466](https://github.com/iTwin/iTwinUI/pull/2466): Fix `Tab`'s stripe positioning when `Tabs.TabList` overflows.
9
+ - [#2469](https://github.com/iTwin/iTwinUI/pull/2469): Fixed `Tabs` bug where orientation related styles of nested tabs were sometimes incorrect.
10
+
11
+ ## 3.17.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#2452](https://github.com/iTwin/iTwinUI/pull/2452): Fixed bug where nested `MenuItem`s in `Tile.MoreOptions` were not closing when clicked.
16
+ - [#2455](https://github.com/iTwin/iTwinUI/pull/2455): Submenus will now correctly portal to the same place as their parent menu (E.g. `DropdownMenu`, `SplitButton`)
17
+ - [#2457](https://github.com/iTwin/iTwinUI/pull/2457): Fixed bug in `ExpandableBlock` where cursor was `pointer` even when it was disabled.
18
+
3
19
  ## 3.17.2
4
20
 
5
21
  ### Patch Changes
@@ -371,27 +371,23 @@ const ComboBox = _react.forwardRef((props, forwardedRef) => {
371
371
  disabled: inputProps?.disabled,
372
372
  ...rest,
373
373
  },
374
- _react.createElement(
375
- _react.Fragment,
376
- null,
377
- _react.createElement(_ComboBoxInput.ComboBoxInput, {
378
- value: inputValue,
379
- disabled: inputProps?.disabled,
380
- ...inputProps,
381
- onChange: handleOnInput,
382
- selectTags: isMultipleEnabled(selectedIndexes, multiple)
383
- ? selectedIndexes
384
- ?.map((index) => {
385
- let item = options[index];
386
- return _react.createElement(_SelectTag.SelectTag, {
387
- key: item.label,
388
- label: item.label,
389
- });
390
- })
391
- .filter(Boolean)
392
- : void 0,
393
- }),
394
- ),
374
+ _react.createElement(_ComboBoxInput.ComboBoxInput, {
375
+ value: inputValue,
376
+ disabled: inputProps?.disabled,
377
+ ...inputProps,
378
+ onChange: handleOnInput,
379
+ selectTags: isMultipleEnabled(selectedIndexes, multiple)
380
+ ? selectedIndexes
381
+ ?.map((index) => {
382
+ let item = options[index];
383
+ return _react.createElement(_SelectTag.SelectTag, {
384
+ key: item.label,
385
+ label: item.label,
386
+ });
387
+ })
388
+ .filter(Boolean)
389
+ : void 0,
390
+ }),
395
391
  _react.createElement(_ComboBoxEndIcon.ComboBoxEndIcon, {
396
392
  ...endIconProps,
397
393
  disabled: inputProps?.disabled,
@@ -65,8 +65,12 @@ const VirtualizedComboBoxMenu = (props) => {
65
65
  [filteredOptions, getMenuItem, children, virtualizer.measureElement],
66
66
  );
67
67
  return _react.createElement(
68
- _react.Fragment,
69
- null,
68
+ 'div',
69
+ {
70
+ style: {
71
+ display: 'contents',
72
+ },
73
+ },
70
74
  _react.createElement(
71
75
  _index.ShadowRoot,
72
76
  {
@@ -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'));
@@ -42,34 +54,50 @@ const DropdownMenuContent = _react.forwardRef((props, forwardedRef) => {
42
54
  visibleProp,
43
55
  onVisibleChange,
44
56
  );
57
+ let close = _react.useCallback(() => {
58
+ setVisible(false);
59
+ }, [setVisible]);
45
60
  let menuContent = _react.useMemo(() => {
46
- if ('function' == typeof menuItems)
47
- return menuItems(() => setVisible(false));
61
+ if ('function' == typeof menuItems) return menuItems(close);
48
62
  return menuItems;
49
- }, [menuItems, setVisible]);
63
+ }, [close, menuItems]);
64
+ let dropdownMenuContextValue = _react.useMemo(
65
+ () => ({
66
+ close,
67
+ }),
68
+ [close],
69
+ );
50
70
  return _react.createElement(
51
- _Menu.Menu,
71
+ DropdownMenuContext.Provider,
52
72
  {
53
- trigger: children,
54
- onKeyDown: (0, _index.mergeEventHandlers)(props.onKeyDown, (e) => {
55
- if (e.defaultPrevented) return;
56
- if ('Tab' === e.key) setVisible(false);
57
- }),
58
- role: role,
59
- ref: forwardedRef,
60
- portal: portal,
61
- popoverProps: _react.useMemo(
62
- () => ({
63
- placement,
64
- matchWidth,
65
- visible,
66
- onVisibleChange: setVisible,
67
- middleware,
68
- }),
69
- [matchWidth, middleware, placement, setVisible, visible],
70
- ),
71
- ...rest,
73
+ value: dropdownMenuContextValue,
72
74
  },
73
- menuContent,
75
+ _react.createElement(
76
+ _Menu.Menu,
77
+ {
78
+ trigger: children,
79
+ onKeyDown: (0, _index.mergeEventHandlers)(props.onKeyDown, (e) => {
80
+ if (e.defaultPrevented) return;
81
+ if ('Tab' === e.key) setVisible(false);
82
+ }),
83
+ role: role,
84
+ ref: forwardedRef,
85
+ portal: portal,
86
+ popoverProps: _react.useMemo(
87
+ () => ({
88
+ placement,
89
+ matchWidth,
90
+ visible,
91
+ onVisibleChange: setVisible,
92
+ middleware,
93
+ }),
94
+ [matchWidth, middleware, placement, setVisible, visible],
95
+ ),
96
+ ...rest,
97
+ },
98
+ menuContent,
99
+ ),
74
100
  );
75
101
  });
102
+ const DropdownMenuContext = _react.createContext(void 0);
103
+ const DropdownMenuCloseOnClickContext = _react.createContext(void 0);
@@ -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,
@@ -41,6 +42,10 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
41
42
  'Passing a non-empty submenuItems array and onClick to MenuItem at the same time is not supported. This is because when a non empty submenuItems array is passed, clicking the MenuItem toggles the submenu visibility.',
42
43
  );
43
44
  let parentMenu = _react.useContext(_Menu.MenuContext);
45
+ let dropdownMenu = _react.useContext(_DropdownMenu.DropdownMenuContext);
46
+ let shouldCloseMenuOnClick = _react.useContext(
47
+ _DropdownMenu.DropdownMenuCloseOnClickContext,
48
+ );
44
49
  let menuItemRef = _react.useRef(null);
45
50
  let submenuId = (0, _index.useId)();
46
51
  let popoverProps = _react.useMemo(
@@ -59,6 +64,7 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
59
64
  );
60
65
  let onClick = () => {
61
66
  if (disabled) return;
67
+ if (shouldCloseMenuOnClick) dropdownMenu?.close();
62
68
  onClickProp?.(value);
63
69
  };
64
70
  let handlers = {
@@ -84,7 +84,9 @@ const TabsWrapper = _react.forwardRef((props, ref) => {
84
84
  TabsWrapper.displayName = 'Tabs.Wrapper';
85
85
  const TabList = _react.forwardRef((props, ref) => {
86
86
  let { className, children, ...rest } = props;
87
- let { type, hasSublabel, color } = (0, _index.useSafeContext)(TabsContext);
87
+ let { type, hasSublabel, color, orientation } = (0, _index.useSafeContext)(
88
+ TabsContext,
89
+ );
88
90
  let isClient = (0, _index.useIsClient)();
89
91
  let tablistRef = _react.useRef(null);
90
92
  let [tablistSizeRef, tabsWidth] = (0, _index.useContainerWidth)(
@@ -110,6 +112,7 @@ const TabList = _react.forwardRef((props, ref) => {
110
112
  },
111
113
  className,
112
114
  ),
115
+ 'data-iui-orientation': orientation,
113
116
  role: 'tablist',
114
117
  ref: refs,
115
118
  ...rest,
@@ -156,10 +159,12 @@ const Tab = _react.forwardRef((props, forwardedRef) => {
156
159
  let updateStripe = () => {
157
160
  let currentTabRect = tabRef.current?.getBoundingClientRect();
158
161
  let tabslistRect = tablistRef.current?.getBoundingClientRect();
162
+ let currentTabLeftIncludingScroll =
163
+ (currentTabRect?.x ?? 0) + (tablistRef.current?.scrollLeft ?? 0);
159
164
  let tabsStripePosition =
160
165
  null != currentTabRect && null != tabslistRect
161
166
  ? {
162
- horizontal: currentTabRect.x - tabslistRect.x,
167
+ horizontal: currentTabLeftIncludingScroll - tabslistRect.x,
163
168
  vertical: currentTabRect.y - tabslistRect.y,
164
169
  }
165
170
  : {
@@ -211,41 +211,39 @@ const TileMoreOptions = _react.forwardRef((props, forwardedRef) => {
211
211
  let { className, children = [], buttonProps, ...rest } = props;
212
212
  let [isMenuVisible, setIsMenuVisible] = _react.useState(false);
213
213
  return _react.createElement(
214
- _index.Box,
214
+ _DropdownMenu.DropdownMenuCloseOnClickContext.Provider,
215
215
  {
216
- className: (0, _classnames.default)(
217
- 'iui-tile-more-options',
218
- {
219
- 'iui-visible': isMenuVisible,
220
- },
221
- className,
222
- ),
223
- ref: forwardedRef,
224
- ...rest,
216
+ value: true,
225
217
  },
226
218
  _react.createElement(
227
- _DropdownMenu.DropdownMenu,
219
+ _index.Box,
228
220
  {
229
- onVisibleChange: setIsMenuVisible,
230
- menuItems: (close) =>
231
- children?.map((option) =>
232
- _react.cloneElement(option, {
233
- onClick: (value) => {
234
- close();
235
- option.props.onClick?.(value);
236
- },
237
- }),
238
- ),
221
+ className: (0, _classnames.default)(
222
+ 'iui-tile-more-options',
223
+ {
224
+ 'iui-visible': isMenuVisible,
225
+ },
226
+ className,
227
+ ),
228
+ ref: forwardedRef,
229
+ ...rest,
239
230
  },
240
231
  _react.createElement(
241
- _IconButton.IconButton,
232
+ _DropdownMenu.DropdownMenu,
242
233
  {
243
- styleType: 'borderless',
244
- size: 'small',
245
- 'aria-label': 'More options',
246
- ...buttonProps,
234
+ onVisibleChange: setIsMenuVisible,
235
+ menuItems: children,
247
236
  },
248
- _react.createElement(_index.SvgMore, null),
237
+ _react.createElement(
238
+ _IconButton.IconButton,
239
+ {
240
+ styleType: 'borderless',
241
+ size: 'small',
242
+ 'aria-label': 'More options',
243
+ ...buttonProps,
244
+ },
245
+ _react.createElement(_index.SvgMore, null),
246
+ ),
249
247
  ),
250
248
  ),
251
249
  );
@@ -217,29 +217,37 @@ const VirtualizedTree = _react.forwardRef(
217
217
  ref: (0, _index.useMergedRefs)(ref, parentRef),
218
218
  },
219
219
  _react.createElement(
220
- _index.ShadowRoot,
220
+ 'div',
221
221
  {
222
- css: virtualizerCss,
222
+ style: {
223
+ display: 'contents',
224
+ },
223
225
  },
224
226
  _react.createElement(
225
- 'div',
227
+ _index.ShadowRoot,
226
228
  {
227
- 'data-iui-virtualizer': 'root',
228
- style: {
229
- minBlockSize: virtualizer.getTotalSize(),
230
- },
229
+ css: virtualizerCss,
231
230
  },
232
- _react.createElement('slot', null),
233
- ),
234
- ),
235
- _react.createElement(
236
- _react.Fragment,
237
- null,
238
- virtualizer
239
- .getVirtualItems()
240
- .map((virtualItem) =>
241
- itemRenderer(virtualItem.index, virtualItem, virtualizer),
231
+ _react.createElement(
232
+ 'div',
233
+ {
234
+ 'data-iui-virtualizer': 'root',
235
+ style: {
236
+ minBlockSize: virtualizer.getTotalSize(),
237
+ },
238
+ },
239
+ _react.createElement('slot', null),
242
240
  ),
241
+ ),
242
+ _react.createElement(
243
+ _react.Fragment,
244
+ null,
245
+ virtualizer
246
+ .getVirtualItems()
247
+ .map((virtualItem) =>
248
+ itemRenderer(virtualItem.index, virtualItem, virtualizer),
249
+ ),
250
+ ),
243
251
  ),
244
252
  );
245
253
  },
package/DEV-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.4';
4
4
  const u = new Proxy(
5
5
  {},
6
6
  {
@@ -367,27 +367,23 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
367
367
  disabled: inputProps?.disabled,
368
368
  ...rest,
369
369
  },
370
- React.createElement(
371
- React.Fragment,
372
- null,
373
- React.createElement(ComboBoxInput, {
374
- value: inputValue,
375
- disabled: inputProps?.disabled,
376
- ...inputProps,
377
- onChange: handleOnInput,
378
- selectTags: isMultipleEnabled(selectedIndexes, multiple)
379
- ? selectedIndexes
380
- ?.map((index) => {
381
- let item = options[index];
382
- return React.createElement(SelectTag, {
383
- key: item.label,
384
- label: item.label,
385
- });
386
- })
387
- .filter(Boolean)
388
- : void 0,
389
- }),
390
- ),
370
+ React.createElement(ComboBoxInput, {
371
+ value: inputValue,
372
+ disabled: inputProps?.disabled,
373
+ ...inputProps,
374
+ onChange: handleOnInput,
375
+ selectTags: isMultipleEnabled(selectedIndexes, multiple)
376
+ ? selectedIndexes
377
+ ?.map((index) => {
378
+ let item = options[index];
379
+ return React.createElement(SelectTag, {
380
+ key: item.label,
381
+ label: item.label,
382
+ });
383
+ })
384
+ .filter(Boolean)
385
+ : void 0,
386
+ }),
391
387
  React.createElement(ComboBoxEndIcon, {
392
388
  ...endIconProps,
393
389
  disabled: inputProps?.disabled,
@@ -59,8 +59,12 @@ let VirtualizedComboBoxMenu = (props) => {
59
59
  [filteredOptions, getMenuItem, children, virtualizer.measureElement],
60
60
  );
61
61
  return React.createElement(
62
- React.Fragment,
63
- null,
62
+ 'div',
63
+ {
64
+ style: {
65
+ display: 'contents',
66
+ },
67
+ },
64
68
  React.createElement(
65
69
  ShadowRoot,
66
70
  {
@@ -31,34 +31,50 @@ let DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
31
31
  visibleProp,
32
32
  onVisibleChange,
33
33
  );
34
+ let close = React.useCallback(() => {
35
+ setVisible(false);
36
+ }, [setVisible]);
34
37
  let menuContent = React.useMemo(() => {
35
- if ('function' == typeof menuItems)
36
- return menuItems(() => setVisible(false));
38
+ if ('function' == typeof menuItems) return menuItems(close);
37
39
  return menuItems;
38
- }, [menuItems, setVisible]);
40
+ }, [close, menuItems]);
41
+ let dropdownMenuContextValue = React.useMemo(
42
+ () => ({
43
+ close,
44
+ }),
45
+ [close],
46
+ );
39
47
  return React.createElement(
40
- Menu,
48
+ DropdownMenuContext.Provider,
41
49
  {
42
- trigger: children,
43
- onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
44
- if (e.defaultPrevented) return;
45
- if ('Tab' === e.key) setVisible(false);
46
- }),
47
- role: role,
48
- ref: forwardedRef,
49
- portal: portal,
50
- popoverProps: React.useMemo(
51
- () => ({
52
- placement,
53
- matchWidth,
54
- visible,
55
- onVisibleChange: setVisible,
56
- middleware,
57
- }),
58
- [matchWidth, middleware, placement, setVisible, visible],
59
- ),
60
- ...rest,
50
+ value: dropdownMenuContextValue,
61
51
  },
62
- menuContent,
52
+ React.createElement(
53
+ Menu,
54
+ {
55
+ trigger: children,
56
+ onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
57
+ if (e.defaultPrevented) return;
58
+ if ('Tab' === e.key) setVisible(false);
59
+ }),
60
+ role: role,
61
+ ref: forwardedRef,
62
+ portal: portal,
63
+ popoverProps: React.useMemo(
64
+ () => ({
65
+ placement,
66
+ matchWidth,
67
+ visible,
68
+ onVisibleChange: setVisible,
69
+ middleware,
70
+ }),
71
+ [matchWidth, middleware, placement, setVisible, visible],
72
+ ),
73
+ ...rest,
74
+ },
75
+ menuContent,
76
+ ),
63
77
  );
64
78
  });
79
+ export const DropdownMenuContext = React.createContext(void 0);
80
+ export const DropdownMenuCloseOnClickContext = React.createContext(void 0);