@itwin/itwinui-react 3.8.0 → 3.8.1

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
+ ## 3.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1964](https://github.com/iTwin/iTwinUI/pull/1964): Fixed a bug with `InformationPanel` where changing orientation after resizing the panel would cause the panel to maintain it's resized width/height.
8
+
3
9
  ## 3.8.0
4
10
 
5
11
  ### Minor Changes
@@ -55,10 +55,11 @@ const index_js_1 = require("../utils/index.js");
55
55
  * </InformationPanel>
56
56
  * </InformationPanelWrapper>
57
57
  */
58
- exports.InformationPanel = React.forwardRef((props, ref) => {
58
+ exports.InformationPanel = React.forwardRef((props, forwardedRef) => {
59
59
  const { className, isOpen = false, orientation = 'vertical', resizable = true, children, ...rest } = props;
60
+ const [infoPanelSize, setInfoPanelSize] = React.useState({ width: undefined, height: undefined });
60
61
  const infoPanelRef = React.useRef(null);
61
- const refs = (0, index_js_1.useMergedRefs)(ref, infoPanelRef);
62
+ const refs = (0, index_js_1.useMergedRefs)(forwardedRef, infoPanelRef);
62
63
  const startResize = (e) => {
63
64
  if (!infoPanelRef.current) {
64
65
  return;
@@ -78,17 +79,21 @@ exports.InformationPanel = React.forwardRef((props, ref) => {
78
79
  }
79
80
  const { right, bottom } = infoPanelRef.current.getBoundingClientRect();
80
81
  if (orientation === 'vertical') {
81
- infoPanelRef.current.style.width = `${right - e.clientX}px`;
82
+ setInfoPanelSize({ width: right - e.clientX, height: undefined });
82
83
  }
83
84
  else {
84
- infoPanelRef.current.style.height = `${bottom - e.clientY}px`;
85
+ setInfoPanelSize({ height: bottom - e.clientY, width: undefined });
85
86
  }
86
87
  }, [orientation]);
87
88
  return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-information-panel', {
88
89
  'iui-right': orientation === 'vertical',
89
90
  'iui-bottom': orientation === 'horizontal',
90
91
  'iui-visible': isOpen,
91
- }, className), ref: refs, ...rest },
92
+ }, className), ref: refs, ...rest, style: {
93
+ width: orientation === 'vertical' ? infoPanelSize.width : undefined,
94
+ height: orientation === 'horizontal' ? infoPanelSize.height : undefined,
95
+ ...props.style,
96
+ } },
92
97
  resizable && (React.createElement(index_js_1.Box, { className: 'iui-resizer', onPointerDown: startResize },
93
98
  React.createElement(index_js_1.Box, { className: 'iui-resizer-bar' }))),
94
99
  children));
@@ -26,10 +26,11 @@ import { useMergedRefs, Box } from '../utils/index.js';
26
26
  * </InformationPanel>
27
27
  * </InformationPanelWrapper>
28
28
  */
29
- export const InformationPanel = React.forwardRef((props, ref) => {
29
+ export const InformationPanel = React.forwardRef((props, forwardedRef) => {
30
30
  const { className, isOpen = false, orientation = 'vertical', resizable = true, children, ...rest } = props;
31
+ const [infoPanelSize, setInfoPanelSize] = React.useState({ width: undefined, height: undefined });
31
32
  const infoPanelRef = React.useRef(null);
32
- const refs = useMergedRefs(ref, infoPanelRef);
33
+ const refs = useMergedRefs(forwardedRef, infoPanelRef);
33
34
  const startResize = (e) => {
34
35
  if (!infoPanelRef.current) {
35
36
  return;
@@ -49,17 +50,21 @@ export const InformationPanel = React.forwardRef((props, ref) => {
49
50
  }
50
51
  const { right, bottom } = infoPanelRef.current.getBoundingClientRect();
51
52
  if (orientation === 'vertical') {
52
- infoPanelRef.current.style.width = `${right - e.clientX}px`;
53
+ setInfoPanelSize({ width: right - e.clientX, height: undefined });
53
54
  }
54
55
  else {
55
- infoPanelRef.current.style.height = `${bottom - e.clientY}px`;
56
+ setInfoPanelSize({ height: bottom - e.clientY, width: undefined });
56
57
  }
57
58
  }, [orientation]);
58
59
  return (React.createElement(Box, { className: cx('iui-information-panel', {
59
60
  'iui-right': orientation === 'vertical',
60
61
  'iui-bottom': orientation === 'horizontal',
61
62
  'iui-visible': isOpen,
62
- }, className), ref: refs, ...rest },
63
+ }, className), ref: refs, ...rest, style: {
64
+ width: orientation === 'vertical' ? infoPanelSize.width : undefined,
65
+ height: orientation === 'horizontal' ? infoPanelSize.height : undefined,
66
+ ...props.style,
67
+ } },
63
68
  resizable && (React.createElement(Box, { className: 'iui-resizer', onPointerDown: startResize },
64
69
  React.createElement(Box, { className: 'iui-resizer-bar' }))),
65
70
  children));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",