Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 17 additions & 26 deletions src/Overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,25 @@ function Overflow<ItemType = any>(
};

// >>>>> Rest node
let restNode: React.ReactNode;
const restContextProps = {
order: displayRest ? mergedDisplayCount : Number.MAX_SAFE_INTEGER,
className: `${itemPrefixCls}-rest`,
registerSize: registerOverflowSize,
display: displayRest,
};

if (!renderRawRest) {
const mergedRenderRest = renderRest || defaultRenderRest;
const mergedRenderRest = renderRest || defaultRenderRest;

restNode = (
const restNode = renderRawRest ? (
<OverflowContext.Provider
value={{
...itemSharedProps,
...restContextProps,
}}
>
{renderRawRest(omittedItems)}
</OverflowContext.Provider>
) : (
<Item
{...itemSharedProps}
// When not show, order should be the last
Expand All @@ -379,20 +386,8 @@ function Overflow<ItemType = any>(
: mergedRenderRest}
</Item>
);
} else if (renderRawRest) {
restNode = (
<OverflowContext.Provider
value={{
...itemSharedProps,
...restContextProps,
}}
>
{renderRawRest(omittedItems)}
</OverflowContext.Provider>
);
}

let overflowNode = (
const overflowNode = (
<Component
className={classNames(!invalidate && prefixCls, className)}
style={style}
Expand Down Expand Up @@ -422,15 +417,11 @@ function Overflow<ItemType = any>(
</Component>
);

if (isResponsive) {
overflowNode = (
<ResizeObserver onResize={onOverflowResize} disabled={!shouldResponsive}>
{overflowNode}
</ResizeObserver>
);
}

return overflowNode;
return isResponsive ? (
<ResizeObserver onResize={onOverflowResize} disabled={!shouldResponsive}>
{overflowNode}
</ResizeObserver>
) : overflowNode;
}

const ForwardOverflow = React.forwardRef(Overflow);
Expand Down
1 change: 0 additions & 1 deletion tests/ssr.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render } from 'enzyme';
import { act } from 'react-dom/test-utils';
import Overflow from '../src';

interface ItemType {
Expand Down