Skip to content

Commit b153c0b

Browse files
committed
SplitterLayout: fix reset behavior
1 parent 9fddb9b commit b153c0b

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build:storybook-sitemap": "node ./scripts/create-storybook-sitemap.js --directory .out",
1616
"test:prepare": "rimraf temp && lerna run build",
1717
"test:open": "CYPRESS_COVERAGE=false cypress open --component --browser chrome",
18-
"test": "yarn test:prepare && cypress run --component --browser chrome --spec packages",
18+
"test": "yarn test:prepare && cypress run --component --browser chrome --spec packages/main/src/components/SplitterLayout",
1919
"clean": "tsc --build --clean && tsc --build tsconfig.build.json --clean && rimraf temp .out && lerna run clean",
2020
"clean:remove-modules": "yarn clean && rimraf node_modules",
2121
"prettier:all": "prettier --write --config ./prettier.config.js \"**/*\"",

packages/main/src/components/SplitterElement/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ const SplitterElement = forwardRef<HTMLDivElement, SplitterElementPropTypes>((pr
5252
const _size = typeof size === 'number' ? `${size}px` : size;
5353
const [flexBasisApplied, setFlexBasisApplied] = useState(false);
5454
const [observedFlex, setObservedFlex] = useState<CSSProperties | null>(null);
55-
const flexStyles =
56-
_size !== 'auto' ? { flex: `0 1 ${_size}` } : (observedFlex ?? { flex: '1 0 min-content', ...safariStyles });
55+
const flexStyles = reset
56+
? undefined
57+
: _size !== 'auto'
58+
? { flex: `0 1 ${_size}` }
59+
: (observedFlex ?? { flex: '1 0 min-content', ...safariStyles });
5760

5861
useStylesheet(styleData, SplitterElement.displayName);
5962
useEffect(() => {
@@ -86,6 +89,8 @@ const SplitterElement = forwardRef<HTMLDivElement, SplitterElementPropTypes>((pr
8689
}
8790
}, [reset]);
8891

92+
console.log(flexStyles, reset);
93+
8994
return (
9095
<div
9196
ref={componentRef}

packages/main/src/internal/useObserveHeights.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const useObserveHeights = (
5454
if (headerContentRef.current && headerCollapsed !== undefined) {
5555
setHeaderContentHeight(headerContentRef.current.getBoundingClientRect().height);
5656
}
57-
}, [headerCollapsed]);
57+
}, [headerCollapsed, headerContentRef]);
5858

5959
useEffect(() => {
6060
const page = pageRef.current;
@@ -64,7 +64,7 @@ export const useObserveHeights = (
6464
return () => {
6565
page.removeEventListener('scroll', onScroll);
6666
};
67-
}, [onScroll, fixedHeader, preserveHeaderStateOnScroll]);
67+
}, [onScroll, fixedHeader, preserveHeaderStateOnScroll, pageRef]);
6868

6969
// top header
7070
useEffect(() => {
@@ -78,7 +78,7 @@ export const useObserveHeights = (
7878
return () => {
7979
headerContentResizeObserver.disconnect();
8080
};
81-
}, []);
81+
}, [topHeaderRef]);
8282

8383
// header content
8484
useEffect(() => {
@@ -95,7 +95,7 @@ export const useObserveHeights = (
9595
return () => {
9696
headerContentResizeObserver.disconnect();
9797
};
98-
}, [isIntersecting, fixedHeader]);
98+
}, [isIntersecting, fixedHeader, headerContentRef]);
9999
const totalHeaderHeight = noHeader ? 0 : topHeaderHeight + headerContentHeight;
100100

101101
return { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed };

packages/main/src/webComponents/Card/Card.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const simpleDataSet = [
7272
];
7373

7474
export const WithAnalyticalCardHeader = {
75-
render: (args) => {
75+
render: () => {
7676
return (
7777
<Card
7878
header={

packages/main/src/webComponents/CheckBox/CheckBox.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Default: Story = {};
2020

2121
export const CheckBoxStates: Story = {
2222
name: 'CheckBox States',
23-
render(args) {
23+
render() {
2424
return (
2525
<>
2626
<CheckBox text="Error" valueState={ValueState.Negative} />

0 commit comments

Comments
 (0)