diff --git a/components/splitter/Panel.tsx b/components/splitter/Panel.tsx index adec5e6cd3..86f4c697f3 100644 --- a/components/splitter/Panel.tsx +++ b/components/splitter/Panel.tsx @@ -11,13 +11,24 @@ export const InternalPanel = forwardRef< const panelClassName = classNames( `${prefixCls}-panel`, { - [`${prefixCls}-panel-hidden`]: !size, + [`${prefixCls}-panel-hidden`]: size === 0, }, className, ); + const hasSize = size !== undefined; + return ( -
+
{children}
); diff --git a/components/splitter/SplitBar.tsx b/components/splitter/SplitBar.tsx index 0884668013..c4bc289e29 100644 --- a/components/splitter/SplitBar.tsx +++ b/components/splitter/SplitBar.tsx @@ -22,6 +22,10 @@ export interface SplitBarProps { ariaMax: number; } +function getValidNumber(num: number | undefined): number { + return typeof num === 'number' && !Number.isNaN(num) ? Math.round(num) : 0; +} + const SplitBar: React.FC = (props) => { const { prefixCls, @@ -112,9 +116,9 @@ const SplitBar: React.FC = (props) => {
> = (props) => { } // ====================== Container ======================= - const [containerSize, setContainerSize] = useState(100); + const [containerSize, setContainerSize] = useState(); const onContainerResize: GetProp = (size) => { const { offsetWidth, offsetHeight } = size; @@ -82,10 +82,8 @@ const Splitter: React.FC> = (props) => { }; // ========================= Size ========================= - const [itemPxSizes, itemPtgSizes, itemPtgMinSizes, itemPtgMaxSizes, updateSizes] = useSizes( - items, - containerSize, - ); + const [panelSizes, itemPxSizes, itemPtgSizes, itemPtgMinSizes, itemPtgMaxSizes, updateSizes] = + useSizes(items, containerSize); // ====================== Resizable ======================= const resizableInfos = useResizable(items, itemPxSizes); @@ -157,7 +155,7 @@ const Splitter: React.FC> = (props) => {
{items.map((item, idx) => { // Panel - const panel = ; + const panel = ; // Split Bar let splitBar: React.ReactElement | null = null; diff --git a/components/splitter/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/splitter/__tests__/__snapshots__/demo-extend.test.ts.snap index a3bfd50747..9ebbbd18c7 100644 --- a/components/splitter/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/splitter/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -10,7 +10,7 @@ exports[`renders components/splitter/demo/collapsible.tsx extend context correct >