@itwin/itwinui-react 3.17.0 → 3.17.2

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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.17.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2442](https://github.com/iTwin/iTwinUI/pull/2442): Removed a leftover `@layer` name, which was originally intended to support _very_ old versions of iTwinUI.
8
+ - [#2443](https://github.com/iTwin/iTwinUI/pull/2443): Fixed bug in `Modal` where focus was sometimes jumping from a modal child to the modal itself.
9
+ - [#2431](https://github.com/iTwin/iTwinUI/pull/2431): Force text wrapping for long words. Affected components: `Text`, `NonIdealState`, `Stepper`, `WorkflowDiagram`.
10
+ - [#2446](https://github.com/iTwin/iTwinUI/pull/2446): Fixed background color in menus when the [theme bridge](https://github.com/iTwin/iTwinUI/wiki/iTwinUI-v5-theme-bridge) is enabled.
11
+
12
+ ## 3.17.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#2436](https://github.com/iTwin/iTwinUI/pull/2436): The **theme bridge** has been updated to handle the breaking changes introduced in `@itwin/itwinui-react@5.0.0-alpha.6`.
17
+ - [#2430](https://github.com/iTwin/iTwinUI/pull/2430): Fixed bug in `SplitButton` where the `dropdownMenuProps.middleware` prop was not respected.
18
+ - [#2430](https://github.com/iTwin/iTwinUI/pull/2430): Fixed a `SplitButton` bug where `dropdownMenuProps` was accidentally being added to the DOM.
19
+ - [#2430](https://github.com/iTwin/iTwinUI/pull/2430): Added missing `div` props in `dropdownMenuProps`'s type for `DropdownButton` and `SplitButton`.
20
+
3
21
  ## 3.17.0
4
22
 
5
23
  ### Minor Changes
@@ -29,9 +29,11 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
29
29
  children,
30
30
  wrapperProps,
31
31
  menuButtonProps,
32
+ dropdownMenuProps,
32
33
  portal = true,
33
34
  ...rest
34
35
  } = props;
36
+ let { middleware, ...dropdownMenuPropsRest } = dropdownMenuProps || {};
35
37
  let [visible, setVisible] = _react.useState(false);
36
38
  let menuContent = _react.useMemo(() => {
37
39
  if ('function' == typeof menuItems)
@@ -43,6 +45,7 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
43
45
  onVisibleChange: setVisible,
44
46
  placement: menuPlacement,
45
47
  matchWidth: true,
48
+ middleware,
46
49
  };
47
50
  let labelId = (0, _index.useId)();
48
51
  let trigger = _react.createElement(
@@ -96,9 +99,13 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
96
99
  trigger: trigger,
97
100
  portal: portal,
98
101
  positionReference: positionReference,
99
- onKeyDown: ({ key }) => {
100
- if ('Tab' === key) setVisible(false);
101
- },
102
+ ...dropdownMenuPropsRest,
103
+ onKeyDown: (0, _index.mergeEventHandlers)(
104
+ dropdownMenuPropsRest?.onKeyDown,
105
+ ({ key }) => {
106
+ if ('Tab' === key) setVisible(false);
107
+ },
108
+ ),
102
109
  },
103
110
  menuContent,
104
111
  ),
@@ -107,7 +107,7 @@ const DialogMain = _react.forwardRef((props, ref) => {
107
107
  dialogRef.current?.focus({
108
108
  preventScroll: true,
109
109
  });
110
- }, [dialogRef, previousFocusedElement, setFocus]);
110
+ }, [setFocus]);
111
111
  let beforeClose = _react.useCallback(() => {
112
112
  if (
113
113
  dialogRef.current?.contains(
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.0';
3
+ const e = '3.17.2';
4
4
  const u = new Proxy(
5
5
  {},
6
6
  {
@@ -11,37 +11,42 @@ Object.defineProperty(exports, 'FocusTrap', {
11
11
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
13
13
  const _focusable = require('../functions/focusable.js');
14
- const _react1 = require('../functions/react.js');
15
14
  const FocusTrap = (props) => {
16
15
  let { children } = props;
17
- let childRef = _react.useRef(void 0);
18
- let getFirstLastFocusables = () => {
19
- let elements = (0, _focusable.getTabbableElements)(childRef.current);
16
+ let firstFocusTrapRef = _react.useRef(null);
17
+ let getFirstLastFocusables = _react.useCallback(() => {
18
+ let childrenElement = firstFocusTrapRef.current?.nextElementSibling;
19
+ let elements = (0, _focusable.getTabbableElements)(childrenElement);
20
20
  let firstElement = elements[0];
21
21
  let lastElement = elements[(elements.length || 1) - 1];
22
22
  return [firstElement, lastElement];
23
- };
24
- let onFirstFocus = (event) => {
25
- let [firstElement, lastElement] = getFirstLastFocusables();
26
- if (event.relatedTarget === firstElement) lastElement?.focus();
27
- else firstElement?.focus();
28
- };
29
- let onLastFocus = (event) => {
30
- let [firstElement, lastElement] = getFirstLastFocusables();
31
- if (event.relatedTarget === lastElement) firstElement?.focus();
32
- else lastElement?.focus();
33
- };
23
+ }, []);
24
+ let onFirstFocus = _react.useCallback(
25
+ (event) => {
26
+ let [firstElement, lastElement] = getFirstLastFocusables();
27
+ if (event.relatedTarget === firstElement) lastElement?.focus();
28
+ else firstElement?.focus();
29
+ },
30
+ [getFirstLastFocusables],
31
+ );
32
+ let onLastFocus = _react.useCallback(
33
+ (event) => {
34
+ let [firstElement, lastElement] = getFirstLastFocusables();
35
+ if (event.relatedTarget === lastElement) firstElement?.focus();
36
+ else lastElement?.focus();
37
+ },
38
+ [getFirstLastFocusables],
39
+ );
34
40
  return _react.createElement(
35
41
  _react.Fragment,
36
42
  null,
37
43
  _react.createElement('div', {
44
+ ref: firstFocusTrapRef,
38
45
  tabIndex: 0,
39
46
  onFocus: onFirstFocus,
40
47
  'aria-hidden': true,
41
48
  }),
42
- (0, _react1.cloneElementWithRef)(children, () => ({
43
- ref: childRef,
44
- })),
49
+ children,
45
50
  _react.createElement('div', {
46
51
  tabIndex: 0,
47
52
  onFocus: onLastFocus,
@@ -4,6 +4,7 @@ import { Button } from './Button.js';
4
4
  import { IconButton } from './IconButton.js';
5
5
  import {
6
6
  Box,
7
+ mergeEventHandlers,
7
8
  SvgCaretDownSmall,
8
9
  SvgCaretUpSmall,
9
10
  useId,
@@ -20,9 +21,11 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
20
21
  children,
21
22
  wrapperProps,
22
23
  menuButtonProps,
24
+ dropdownMenuProps,
23
25
  portal = true,
24
26
  ...rest
25
27
  } = props;
28
+ let { middleware, ...dropdownMenuPropsRest } = dropdownMenuProps || {};
26
29
  let [visible, setVisible] = React.useState(false);
27
30
  let menuContent = React.useMemo(() => {
28
31
  if ('function' == typeof menuItems)
@@ -34,6 +37,7 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
34
37
  onVisibleChange: setVisible,
35
38
  placement: menuPlacement,
36
39
  matchWidth: true,
40
+ middleware,
37
41
  };
38
42
  let labelId = useId();
39
43
  let trigger = React.createElement(
@@ -87,9 +91,13 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
87
91
  trigger: trigger,
88
92
  portal: portal,
89
93
  positionReference: positionReference,
90
- onKeyDown: ({ key }) => {
91
- if ('Tab' === key) setVisible(false);
92
- },
94
+ ...dropdownMenuPropsRest,
95
+ onKeyDown: mergeEventHandlers(
96
+ dropdownMenuPropsRest?.onKeyDown,
97
+ ({ key }) => {
98
+ if ('Tab' === key) setVisible(false);
99
+ },
100
+ ),
93
101
  },
94
102
  menuContent,
95
103
  ),
@@ -101,7 +101,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
101
101
  dialogRef.current?.focus({
102
102
  preventScroll: true,
103
103
  });
104
- }, [dialogRef, previousFocusedElement, setFocus]);
104
+ }, [setFocus]);
105
105
  let beforeClose = React.useCallback(() => {
106
106
  if (
107
107
  dialogRef.current?.contains(
package/DEV-esm/styles.js CHANGED
@@ -1,4 +1,4 @@
1
- const t = '3.17.0';
1
+ const t = '3.17.2';
2
2
  const u = new Proxy(
3
3
  {},
4
4
  {
@@ -1,36 +1,41 @@
1
1
  import * as React from 'react';
2
2
  import { getTabbableElements } from '../functions/focusable.js';
3
- import { cloneElementWithRef } from '../functions/react.js';
4
3
  export const FocusTrap = (props) => {
5
4
  let { children } = props;
6
- let childRef = React.useRef(void 0);
7
- let getFirstLastFocusables = () => {
8
- let elements = getTabbableElements(childRef.current);
5
+ let firstFocusTrapRef = React.useRef(null);
6
+ let getFirstLastFocusables = React.useCallback(() => {
7
+ let childrenElement = firstFocusTrapRef.current?.nextElementSibling;
8
+ let elements = getTabbableElements(childrenElement);
9
9
  let firstElement = elements[0];
10
10
  let lastElement = elements[(elements.length || 1) - 1];
11
11
  return [firstElement, lastElement];
12
- };
13
- let onFirstFocus = (event) => {
14
- let [firstElement, lastElement] = getFirstLastFocusables();
15
- if (event.relatedTarget === firstElement) lastElement?.focus();
16
- else firstElement?.focus();
17
- };
18
- let onLastFocus = (event) => {
19
- let [firstElement, lastElement] = getFirstLastFocusables();
20
- if (event.relatedTarget === lastElement) firstElement?.focus();
21
- else lastElement?.focus();
22
- };
12
+ }, []);
13
+ let onFirstFocus = React.useCallback(
14
+ (event) => {
15
+ let [firstElement, lastElement] = getFirstLastFocusables();
16
+ if (event.relatedTarget === firstElement) lastElement?.focus();
17
+ else firstElement?.focus();
18
+ },
19
+ [getFirstLastFocusables],
20
+ );
21
+ let onLastFocus = React.useCallback(
22
+ (event) => {
23
+ let [firstElement, lastElement] = getFirstLastFocusables();
24
+ if (event.relatedTarget === lastElement) firstElement?.focus();
25
+ else lastElement?.focus();
26
+ },
27
+ [getFirstLastFocusables],
28
+ );
23
29
  return React.createElement(
24
30
  React.Fragment,
25
31
  null,
26
32
  React.createElement('div', {
33
+ ref: firstFocusTrapRef,
27
34
  tabIndex: 0,
28
35
  onFocus: onFirstFocus,
29
36
  'aria-hidden': true,
30
37
  }),
31
- cloneElementWithRef(children, () => ({
32
- ref: childRef,
33
- })),
38
+ children,
34
39
  React.createElement('div', {
35
40
  tabIndex: 0,
36
41
  onFocus: onLastFocus,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ButtonProps } from './Button.js';
3
- import type { DropdownMenuProps } from '../DropdownMenu/DropdownMenu.js';
3
+ import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
4
4
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
5
5
  export type DropdownButtonProps = {
6
6
  /**
@@ -16,9 +16,9 @@ export type DropdownButtonProps = {
16
16
  */
17
17
  styleType?: 'default' | 'borderless' | 'high-visibility';
18
18
  /**
19
- * Props for the `DropdownMenu` which extends `PopoverProps`.
19
+ * Props for the `DropdownMenu` which extends the props of `Popover`.
20
20
  */
21
- dropdownMenuProps?: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
21
+ dropdownMenuProps?: Omit<React.ComponentProps<typeof DropdownMenu>, 'menuItems' | 'children'>;
22
22
  } & Omit<ButtonProps, 'styleType' | 'endIcon'>;
23
23
  /**
24
24
  * Button that opens a DropdownMenu.
@@ -31,7 +31,7 @@ export type SplitButtonProps = ButtonProps & {
31
31
  /**
32
32
  * Props to customize menu behavior.
33
33
  */
34
- dropdownMenuProps?: Pick<Parameters<typeof usePopover>[0], 'middleware'>;
34
+ dropdownMenuProps?: Pick<Parameters<typeof usePopover>[0], 'middleware'> & React.ComponentProps<'div'>;
35
35
  } & Pick<PortalProps, 'portal'>;
36
36
  /**
37
37
  * Split button component with a DropdownMenu.
@@ -29,9 +29,11 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
29
29
  children,
30
30
  wrapperProps,
31
31
  menuButtonProps,
32
+ dropdownMenuProps,
32
33
  portal = true,
33
34
  ...rest
34
35
  } = props;
36
+ let { middleware, ...dropdownMenuPropsRest } = dropdownMenuProps || {};
35
37
  let [visible, setVisible] = _react.useState(false);
36
38
  let menuContent = _react.useMemo(() => {
37
39
  if ('function' == typeof menuItems)
@@ -43,6 +45,7 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
43
45
  onVisibleChange: setVisible,
44
46
  placement: menuPlacement,
45
47
  matchWidth: true,
48
+ middleware,
46
49
  };
47
50
  let labelId = (0, _index.useId)();
48
51
  let trigger = _react.createElement(
@@ -96,9 +99,13 @@ const SplitButton = _react.forwardRef((props, forwardedRef) => {
96
99
  trigger: trigger,
97
100
  portal: portal,
98
101
  positionReference: positionReference,
99
- onKeyDown: ({ key }) => {
100
- if ('Tab' === key) setVisible(false);
101
- },
102
+ ...dropdownMenuPropsRest,
103
+ onKeyDown: (0, _index.mergeEventHandlers)(
104
+ dropdownMenuPropsRest?.onKeyDown,
105
+ ({ key }) => {
106
+ if ('Tab' === key) setVisible(false);
107
+ },
108
+ ),
102
109
  },
103
110
  menuContent,
104
111
  ),
@@ -107,7 +107,7 @@ const DialogMain = _react.forwardRef((props, ref) => {
107
107
  dialogRef.current?.focus({
108
108
  preventScroll: true,
109
109
  });
110
- }, [dialogRef, previousFocusedElement, setFocus]);
110
+ }, [setFocus]);
111
111
  let beforeClose = _react.useCallback(() => {
112
112
  if (
113
113
  dialogRef.current?.contains(
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.0';
3
+ const e = '3.17.2';
4
4
  const u = new Proxy(
5
5
  {},
6
6
  {
@@ -11,37 +11,42 @@ Object.defineProperty(exports, 'FocusTrap', {
11
11
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
13
13
  const _focusable = require('../functions/focusable.js');
14
- const _react1 = require('../functions/react.js');
15
14
  const FocusTrap = (props) => {
16
15
  let { children } = props;
17
- let childRef = _react.useRef(void 0);
18
- let getFirstLastFocusables = () => {
19
- let elements = (0, _focusable.getTabbableElements)(childRef.current);
16
+ let firstFocusTrapRef = _react.useRef(null);
17
+ let getFirstLastFocusables = _react.useCallback(() => {
18
+ let childrenElement = firstFocusTrapRef.current?.nextElementSibling;
19
+ let elements = (0, _focusable.getTabbableElements)(childrenElement);
20
20
  let firstElement = elements[0];
21
21
  let lastElement = elements[(elements.length || 1) - 1];
22
22
  return [firstElement, lastElement];
23
- };
24
- let onFirstFocus = (event) => {
25
- let [firstElement, lastElement] = getFirstLastFocusables();
26
- if (event.relatedTarget === firstElement) lastElement?.focus();
27
- else firstElement?.focus();
28
- };
29
- let onLastFocus = (event) => {
30
- let [firstElement, lastElement] = getFirstLastFocusables();
31
- if (event.relatedTarget === lastElement) firstElement?.focus();
32
- else lastElement?.focus();
33
- };
23
+ }, []);
24
+ let onFirstFocus = _react.useCallback(
25
+ (event) => {
26
+ let [firstElement, lastElement] = getFirstLastFocusables();
27
+ if (event.relatedTarget === firstElement) lastElement?.focus();
28
+ else firstElement?.focus();
29
+ },
30
+ [getFirstLastFocusables],
31
+ );
32
+ let onLastFocus = _react.useCallback(
33
+ (event) => {
34
+ let [firstElement, lastElement] = getFirstLastFocusables();
35
+ if (event.relatedTarget === lastElement) firstElement?.focus();
36
+ else lastElement?.focus();
37
+ },
38
+ [getFirstLastFocusables],
39
+ );
34
40
  return _react.createElement(
35
41
  _react.Fragment,
36
42
  null,
37
43
  _react.createElement('div', {
44
+ ref: firstFocusTrapRef,
38
45
  tabIndex: 0,
39
46
  onFocus: onFirstFocus,
40
47
  'aria-hidden': true,
41
48
  }),
42
- (0, _react1.cloneElementWithRef)(children, () => ({
43
- ref: childRef,
44
- })),
49
+ children,
45
50
  _react.createElement('div', {
46
51
  tabIndex: 0,
47
52
  onFocus: onLastFocus,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ButtonProps } from './Button.js';
3
- import type { DropdownMenuProps } from '../DropdownMenu/DropdownMenu.js';
3
+ import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
4
4
  import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
5
5
  export type DropdownButtonProps = {
6
6
  /**
@@ -16,9 +16,9 @@ export type DropdownButtonProps = {
16
16
  */
17
17
  styleType?: 'default' | 'borderless' | 'high-visibility';
18
18
  /**
19
- * Props for the `DropdownMenu` which extends `PopoverProps`.
19
+ * Props for the `DropdownMenu` which extends the props of `Popover`.
20
20
  */
21
- dropdownMenuProps?: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
21
+ dropdownMenuProps?: Omit<React.ComponentProps<typeof DropdownMenu>, 'menuItems' | 'children'>;
22
22
  } & Omit<ButtonProps, 'styleType' | 'endIcon'>;
23
23
  /**
24
24
  * Button that opens a DropdownMenu.
@@ -31,7 +31,7 @@ export type SplitButtonProps = ButtonProps & {
31
31
  /**
32
32
  * Props to customize menu behavior.
33
33
  */
34
- dropdownMenuProps?: Pick<Parameters<typeof usePopover>[0], 'middleware'>;
34
+ dropdownMenuProps?: Pick<Parameters<typeof usePopover>[0], 'middleware'> & React.ComponentProps<'div'>;
35
35
  } & Pick<PortalProps, 'portal'>;
36
36
  /**
37
37
  * Split button component with a DropdownMenu.
@@ -4,6 +4,7 @@ import { Button } from './Button.js';
4
4
  import { IconButton } from './IconButton.js';
5
5
  import {
6
6
  Box,
7
+ mergeEventHandlers,
7
8
  SvgCaretDownSmall,
8
9
  SvgCaretUpSmall,
9
10
  useId,
@@ -20,9 +21,11 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
20
21
  children,
21
22
  wrapperProps,
22
23
  menuButtonProps,
24
+ dropdownMenuProps,
23
25
  portal = true,
24
26
  ...rest
25
27
  } = props;
28
+ let { middleware, ...dropdownMenuPropsRest } = dropdownMenuProps || {};
26
29
  let [visible, setVisible] = React.useState(false);
27
30
  let menuContent = React.useMemo(() => {
28
31
  if ('function' == typeof menuItems)
@@ -34,6 +37,7 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
34
37
  onVisibleChange: setVisible,
35
38
  placement: menuPlacement,
36
39
  matchWidth: true,
40
+ middleware,
37
41
  };
38
42
  let labelId = useId();
39
43
  let trigger = React.createElement(
@@ -87,9 +91,13 @@ export const SplitButton = React.forwardRef((props, forwardedRef) => {
87
91
  trigger: trigger,
88
92
  portal: portal,
89
93
  positionReference: positionReference,
90
- onKeyDown: ({ key }) => {
91
- if ('Tab' === key) setVisible(false);
92
- },
94
+ ...dropdownMenuPropsRest,
95
+ onKeyDown: mergeEventHandlers(
96
+ dropdownMenuPropsRest?.onKeyDown,
97
+ ({ key }) => {
98
+ if ('Tab' === key) setVisible(false);
99
+ },
100
+ ),
93
101
  },
94
102
  menuContent,
95
103
  ),
@@ -101,7 +101,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
101
101
  dialogRef.current?.focus({
102
102
  preventScroll: true,
103
103
  });
104
- }, [dialogRef, previousFocusedElement, setFocus]);
104
+ }, [setFocus]);
105
105
  let beforeClose = React.useCallback(() => {
106
106
  if (
107
107
  dialogRef.current?.contains(
package/esm/styles.js CHANGED
@@ -1,4 +1,4 @@
1
- const t = '3.17.0';
1
+ const t = '3.17.2';
2
2
  const u = new Proxy(
3
3
  {},
4
4
  {
@@ -1,36 +1,41 @@
1
1
  import * as React from 'react';
2
2
  import { getTabbableElements } from '../functions/focusable.js';
3
- import { cloneElementWithRef } from '../functions/react.js';
4
3
  export const FocusTrap = (props) => {
5
4
  let { children } = props;
6
- let childRef = React.useRef(void 0);
7
- let getFirstLastFocusables = () => {
8
- let elements = getTabbableElements(childRef.current);
5
+ let firstFocusTrapRef = React.useRef(null);
6
+ let getFirstLastFocusables = React.useCallback(() => {
7
+ let childrenElement = firstFocusTrapRef.current?.nextElementSibling;
8
+ let elements = getTabbableElements(childrenElement);
9
9
  let firstElement = elements[0];
10
10
  let lastElement = elements[(elements.length || 1) - 1];
11
11
  return [firstElement, lastElement];
12
- };
13
- let onFirstFocus = (event) => {
14
- let [firstElement, lastElement] = getFirstLastFocusables();
15
- if (event.relatedTarget === firstElement) lastElement?.focus();
16
- else firstElement?.focus();
17
- };
18
- let onLastFocus = (event) => {
19
- let [firstElement, lastElement] = getFirstLastFocusables();
20
- if (event.relatedTarget === lastElement) firstElement?.focus();
21
- else lastElement?.focus();
22
- };
12
+ }, []);
13
+ let onFirstFocus = React.useCallback(
14
+ (event) => {
15
+ let [firstElement, lastElement] = getFirstLastFocusables();
16
+ if (event.relatedTarget === firstElement) lastElement?.focus();
17
+ else firstElement?.focus();
18
+ },
19
+ [getFirstLastFocusables],
20
+ );
21
+ let onLastFocus = React.useCallback(
22
+ (event) => {
23
+ let [firstElement, lastElement] = getFirstLastFocusables();
24
+ if (event.relatedTarget === lastElement) firstElement?.focus();
25
+ else lastElement?.focus();
26
+ },
27
+ [getFirstLastFocusables],
28
+ );
23
29
  return React.createElement(
24
30
  React.Fragment,
25
31
  null,
26
32
  React.createElement('div', {
33
+ ref: firstFocusTrapRef,
27
34
  tabIndex: 0,
28
35
  onFocus: onFirstFocus,
29
36
  'aria-hidden': true,
30
37
  }),
31
- cloneElementWithRef(children, () => ({
32
- ref: childRef,
33
- })),
38
+ children,
34
39
  React.createElement('div', {
35
40
  tabIndex: 0,
36
41
  onFocus: onLastFocus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.17.0",
3
+ "version": "3.17.2",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",