diff --git a/components/lib/splitter/Splitter.js b/components/lib/splitter/Splitter.js index ca82ddeb30..1a8e091aa3 100644 --- a/components/lib/splitter/Splitter.js +++ b/components/lib/splitter/Splitter.js @@ -187,24 +187,18 @@ export const Splitter = React.memo( }; const onResizeEnd = (event) => { - setPanelSizes((prev) => { - const sizes = []; - - for (let index = 0; index < props.children.length; index++) sizes[index] = panelSize(prev, index); - sizes[prevPanelIndex.current] = prevPanelSizeNew.current; - sizes[prevPanelIndex.current + 1] = nextPanelSizeNew.current; - - if (props.onResizeEnd) { - props.onResizeEnd({ - originalEvent: event, - sizes - }); - } + const sizes = [prevPanelSizeNew.current, nextPanelSizeNew.current]; + + if (props.onResizeEnd) { + props.onResizeEnd({ + originalEvent: event, + sizes + }); + } - if (isStateful) saveState(sizes); + if (isStateful) saveState(sizes); - return sizes; - }); + setPanelSizes(sizes); !isUnstyled() && DomHandler.removeClass(gutterRef.current, 'p-splitter-gutter-resizing'); gutterRefs.current && Object.keys(gutterRefs.current).forEach((key) => gutterRefs.current[key].setAttribute('data-p-splitter-gutter-resizing', false));