Skip to content

Commit 27f2bd6

Browse files
authored
fix: Missing props (#8)
* fix: Missing props * test: Update test case
1 parent 2bfaeba commit 27f2bd6

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

src/Item.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function Item<ItemType>(props: ItemProps<ItemType>) {
3232
display,
3333
order,
3434
component: Component,
35+
...restProps
3536
} = props;
3637

3738
const mergedHidden = responsive && !display;
@@ -62,6 +63,7 @@ export default function Item<ItemType>(props: ItemProps<ItemType>) {
6263
pointerEvents: mergedHidden ? 'none' : undefined,
6364
...style,
6465
}}
66+
{...restProps}
6567
>
6668
{childNode}
6769
</Component>

src/Overflow.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type ComponentType =
1313
| React.FC<any>
1414
| keyof React.ReactHTML;
1515

16-
export interface OverflowProps<ItemType> {
16+
export interface OverflowProps<ItemType> extends React.HTMLAttributes<any> {
1717
prefixCls?: string;
1818
className?: string;
1919
style?: React.CSSProperties;
@@ -22,6 +22,7 @@ export interface OverflowProps<ItemType> {
2222
/** Used for `responsive`. It will limit render node to avoid perf issue */
2323
itemWidth?: number;
2424
renderItem?: (item: ItemType) => React.ReactNode;
25+
renderItemProps?: (item: ItemType) => React.HTMLAttributes<any>;
2526
maxCount?: number | typeof RESPONSIVE;
2627
renderRest?:
2728
| React.ReactNode
@@ -49,9 +50,11 @@ function Overflow<ItemType = any>(
4950
className,
5051
maxCount,
5152
renderRest = defaultRenderRest,
53+
renderItemProps,
5254
suffix,
5355
component: Component = 'div',
54-
itemComponent = 'div'
56+
itemComponent = 'div',
57+
...restProps
5558
} = props;
5659

5760
const createUseState = useBatchFrameState();
@@ -236,6 +239,7 @@ function Overflow<ItemType = any>(
236239
className={classNames(prefixCls, className)}
237240
style={style}
238241
ref={ref}
242+
{...restProps}
239243
>
240244
{mergedData.map((item, index) => {
241245
const key = getKey(item, index);
@@ -250,6 +254,7 @@ function Overflow<ItemType = any>(
250254
itemKey={key}
251255
registerSize={registerSize}
252256
display={index <= displayCount}
257+
{...renderItemProps?.(item)}
253258
/>
254259
);
255260
})}

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Overflow aria props 1`] = `
4+
<div
5+
class="rc-overflow"
6+
role="menu"
7+
>
8+
<div
9+
class="rc-overflow-item"
10+
role="menuitem"
11+
style="opacity: 1;"
12+
>
13+
Label 0
14+
</div>
15+
</div>
16+
`;
17+
318
exports[`Overflow customize component 1`] = `
419
<ul
520
class="rc-overflow"

tests/index.spec.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,18 @@ describe('Overflow', () => {
113113

114114
expect(wrapper.render()).toMatchSnapshot();
115115
});
116+
117+
it('aria props', () => {
118+
const wrapper = mount(
119+
<Overflow
120+
data={getData(1)}
121+
renderItem={renderItem}
122+
renderItemProps={() => ({ role: 'menuitem' })}
123+
itemKey={(item) => `bamboo-${item.key}`}
124+
role="menu"
125+
/>,
126+
);
127+
128+
expect(wrapper.render()).toMatchSnapshot();
129+
});
116130
});

0 commit comments

Comments
 (0)