@itwin/itwinui-react 2.0.2 → 2.0.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 2.0.3 (2022-12-12)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
* **ComboBox:** Move max-height to outer element to fix virtual scroll ([#986](https://www.github.com/iTwin/iTwinUI-react/issues/986))
|
|
8
|
+
|
|
3
9
|
### [2.0.2](https://www.github.com/iTwin/iTwinUI-react/compare/v2.0.1...v2.0.2) (2022-12-07)
|
|
4
10
|
|
|
5
11
|
### Fixes
|
|
@@ -14,8 +14,8 @@ const Menu_1 = require("../Menu");
|
|
|
14
14
|
const Surface_1 = require("../Surface");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
16
|
const helpers_1 = require("./helpers");
|
|
17
|
+
const isOverflowOverlaySupported = () => { var _a, _b, _c; return (_c = (_b = (_a = (0, utils_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow: overlay'); };
|
|
17
18
|
const VirtualizedComboBoxMenu = react_1.default.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
|
|
18
|
-
var _a, _b, _c;
|
|
19
19
|
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxStateContext);
|
|
20
20
|
const { menuRef } = (0, utils_1.useSafeContext)(helpers_1.ComboBoxRefsContext);
|
|
21
21
|
const virtualItemRenderer = react_1.default.useCallback((index) => filteredOptions.length > 0
|
|
@@ -37,16 +37,17 @@ const VirtualizedComboBoxMenu = react_1.default.forwardRef(({ children, classNam
|
|
|
37
37
|
itemRenderer: virtualItemRenderer,
|
|
38
38
|
scrollToIndex: focusedVisibleIndex,
|
|
39
39
|
});
|
|
40
|
-
const
|
|
41
|
-
? { overflowY: 'overlay' }
|
|
42
|
-
: { overflowY: 'auto' };
|
|
43
|
-
const styles = react_1.default.useMemo(() => ({
|
|
40
|
+
const surfaceStyles = {
|
|
44
41
|
minWidth,
|
|
45
42
|
maxWidth: `min(${minWidth * 2}px, 90vw)`,
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
// max-height must be on the outermost element for virtual scroll
|
|
44
|
+
maxHeight: 'calc((var(--iui-component-height) - 1px) * 8.5)',
|
|
45
|
+
overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
|
|
46
|
+
...style,
|
|
47
|
+
};
|
|
48
|
+
return (react_1.default.createElement(Surface_1.Surface, { style: surfaceStyles, ...rest },
|
|
48
49
|
react_1.default.createElement("div", { ...outerProps },
|
|
49
|
-
react_1.default.createElement(Menu_1.Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: (0, utils_1.mergeRefs)(menuRef, innerProps.ref, forwardedRef), className:
|
|
50
|
+
react_1.default.createElement(Menu_1.Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: (0, utils_1.mergeRefs)(menuRef, innerProps.ref, forwardedRef), className: className, style: innerProps.style }, visibleChildren))));
|
|
50
51
|
});
|
|
51
52
|
exports.ComboBoxMenu = react_1.default.forwardRef((props, forwardedRef) => {
|
|
52
53
|
const { className, style, ...rest } = props;
|
|
@@ -8,8 +8,8 @@ import { Menu } from '../Menu';
|
|
|
8
8
|
import { Surface } from '../Surface';
|
|
9
9
|
import { useSafeContext, useMergedRefs, useVirtualization, mergeRefs, getWindow, } from '../utils';
|
|
10
10
|
import { ComboBoxStateContext, ComboBoxRefsContext } from './helpers';
|
|
11
|
+
const isOverflowOverlaySupported = () => { var _a, _b, _c; return (_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, 'overflow: overlay'); };
|
|
11
12
|
const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
|
|
12
|
-
var _a, _b, _c;
|
|
13
13
|
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = useSafeContext(ComboBoxStateContext);
|
|
14
14
|
const { menuRef } = useSafeContext(ComboBoxRefsContext);
|
|
15
15
|
const virtualItemRenderer = React.useCallback((index) => filteredOptions.length > 0
|
|
@@ -31,16 +31,17 @@ const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style,
|
|
|
31
31
|
itemRenderer: virtualItemRenderer,
|
|
32
32
|
scrollToIndex: focusedVisibleIndex,
|
|
33
33
|
});
|
|
34
|
-
const
|
|
35
|
-
? { overflowY: 'overlay' }
|
|
36
|
-
: { overflowY: 'auto' };
|
|
37
|
-
const styles = React.useMemo(() => ({
|
|
34
|
+
const surfaceStyles = {
|
|
38
35
|
minWidth,
|
|
39
36
|
maxWidth: `min(${minWidth * 2}px, 90vw)`,
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
// max-height must be on the outermost element for virtual scroll
|
|
38
|
+
maxHeight: 'calc((var(--iui-component-height) - 1px) * 8.5)',
|
|
39
|
+
overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
|
|
40
|
+
...style,
|
|
41
|
+
};
|
|
42
|
+
return (React.createElement(Surface, { style: surfaceStyles, ...rest },
|
|
42
43
|
React.createElement("div", { ...outerProps },
|
|
43
|
-
React.createElement(Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), className:
|
|
44
|
+
React.createElement(Menu, { id: `${id}-list`, setFocus: false, role: 'listbox', ref: mergeRefs(menuRef, innerProps.ref, forwardedRef), className: className, style: innerProps.style }, visibleChildren))));
|
|
44
45
|
});
|
|
45
46
|
export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
|
|
46
47
|
const { className, style, ...rest } = props;
|