Skip to content

Commit

Permalink
Fix #3413: Splitter strict mode rendering (#3416)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Oct 4, 2022
1 parent 84468cd commit e312d0c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions components/lib/splitter/Splitter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { DomHandler, classNames, ObjectUtils } from '../utils/Utils';
import { useEventListener } from '../hooks/Hooks';
import { useEventListener, useMountEffect } from '../hooks/Hooks';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';

export const SplitterPanel = () => {};

Expand Down Expand Up @@ -178,7 +178,11 @@ export const Splitter = React.memo(
getElement: () => elementRef.current
}));

React.useEffect(() => {
useMountEffect(() => {
if (mounted.current) {
return;
}

let panelElements = [...elementRef.current.children].filter((child) => DomHandler.hasClass(child, 'p-splitter-panel'));

panelElements.map((panelElement) => {
Expand All @@ -190,7 +194,7 @@ export const Splitter = React.memo(
if (props.children && props.children.length) {
let initialized = false;

if (isStateful && !mounted.current) {
if (isStateful) {
initialized = restoreState();
}

Expand All @@ -209,7 +213,7 @@ export const Splitter = React.memo(

panelSizes.current = _panelSizes;

mounted.current && saveState();
saveState();
}
}

Expand Down Expand Up @@ -263,21 +267,21 @@ export const Splitter = React.memo(
SplitterPanel.displayName = 'SplitterPanel';
SplitterPanel.defaultProps = {
__TYPE: 'SplitterPanel',
size: null,
className: null,
minSize: null,
style: null,
className: null
size: null,
style: null
};

Splitter.displayName = 'Splitter';
Splitter.defaultProps = {
__TYPE: 'Splitter',
id: null,
className: null,
style: null,
layout: 'horizontal',
gutterSize: 4,
id: null,
layout: 'horizontal',
onResizeEnd: null,
stateKey: null,
stateStorage: 'session',
onResizeEnd: null
style: null
};

0 comments on commit e312d0c

Please sign in to comment.