Skip to content

Commit b43a524

Browse files
authored
fix(Chip): spread fewer props (#8584)
* fix(Chip): spread fewer props * fix snapshots
1 parent 91180fe commit b43a524

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

packages/react-core/src/components/Chip/Chip.tsx

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,34 @@ export class Chip extends React.Component<ChipProps, ChipState> {
8383
});
8484

8585
renderOverflowChip = () => {
86-
const { children, className, onClick, ouiaId, ...props } = this.props;
87-
const Component = this.props.component as any;
86+
const {
87+
children,
88+
className,
89+
onClick,
90+
ouiaId,
91+
textMaxWidth,
92+
style,
93+
component,
94+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
95+
tooltipPosition,
96+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
97+
isOverflowChip,
98+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
99+
closeBtnAriaLabel,
100+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
101+
isReadOnly,
102+
...props
103+
} = this.props;
104+
const Component = component as any;
88105
return (
89106
<Component
90107
onClick={onClick}
91-
{...(this.props.textMaxWidth && {
108+
{...(textMaxWidth && {
92109
style: this.setChipStyle(),
93-
...this.props.style
110+
...style
94111
})}
95112
className={css(styles.chip, styles.modifiers.overflow, className)}
96-
{...(this.props.component === 'button' ? { type: 'button' } : {})}
113+
{...(component === 'button' ? { type: 'button' } : {})}
97114
{...getOUIAProps('OverflowChip', ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
98115
{...props}
99116
>
@@ -103,7 +120,20 @@ export class Chip extends React.Component<ChipProps, ChipState> {
103120
};
104121

105122
renderInnerChip(id: string) {
106-
const { children, className, onClick, closeBtnAriaLabel, isReadOnly, component, ouiaId, ...props } = this.props;
123+
const {
124+
children,
125+
className,
126+
onClick,
127+
closeBtnAriaLabel,
128+
isReadOnly,
129+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
130+
isOverflowChip,
131+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
132+
tooltipPosition,
133+
component,
134+
ouiaId,
135+
...props
136+
} = this.props;
107137
const Component = component as any;
108138
return (
109139
<Component

packages/react-core/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ exports[`Chip closable 1`] = `
88
data-ouia-component-type="PF4/Chip"
99
data-ouia-safe="true"
1010
id="chip_one"
11-
tooltipposition="top"
1211
>
1312
<span
1413
class="pf-c-chip__text"
@@ -53,7 +52,6 @@ exports[`Chip closable with tooltip 1`] = `
5352
data-ouia-component-type="PF4/Chip"
5453
data-ouia-safe="true"
5554
id="chip_one"
56-
tooltipposition="top"
5755
>
5856
<span
5957
class="pf-c-chip__text"
@@ -99,7 +97,6 @@ exports[`Chip custom max-width text 1`] = `
9997
data-ouia-safe="true"
10098
style="--pf-c-chip__text--MaxWidth: 100px;"
10199
textmaxwidth="100px"
102-
tooltipposition="top"
103100
>
104101
<span
105102
class="pf-c-chip__text"
@@ -140,12 +137,9 @@ exports[`Chip overflow 1`] = `
140137
<DocumentFragment>
141138
<div
142139
class="pf-c-chip pf-m-overflow my-chp-cls"
143-
closebtnarialabel="close"
144-
component="div"
145140
data-ouia-component-id="OUIA-Generated-Chip-1"
146141
data-ouia-component-type="PF4/OverflowChip"
147142
data-ouia-safe="true"
148-
tooltipposition="top"
149143
>
150144
<span
151145
class="pf-c-chip__text"
@@ -163,7 +157,6 @@ exports[`Chip readonly 1`] = `
163157
data-ouia-component-id="OUIA-Generated-Chip-4"
164158
data-ouia-component-type="PF4/Chip"
165159
data-ouia-safe="true"
166-
tooltipposition="top"
167160
>
168161
<span
169162
class="pf-c-chip__text"
@@ -183,7 +176,6 @@ exports[`Chip with role='gridcell' 1`] = `
183176
data-ouia-component-type="PF4/Chip"
184177
data-ouia-safe="true"
185178
role="gridcell"
186-
tooltipposition="top"
187179
>
188180
<span
189181
class="pf-c-chip__text"

packages/react-core/src/components/ChipGroup/__tests__/__snapshots__/ChipGroup.test.tsx.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ exports[`ChipGroup chip group default 1`] = `
2525
data-ouia-component-id="OUIA-Generated-Chip-1"
2626
data-ouia-component-type="PF4/Chip"
2727
data-ouia-safe="true"
28-
tooltipposition="top"
2928
>
3029
<span
3130
class="pf-c-chip__text"
@@ -97,7 +96,6 @@ exports[`ChipGroup chip group with category 1`] = `
9796
data-ouia-component-id="OUIA-Generated-Chip-2"
9897
data-ouia-component-type="PF4/Chip"
9998
data-ouia-safe="true"
100-
tooltipposition="top"
10199
>
102100
<span
103101
class="pf-c-chip__text"
@@ -169,7 +167,6 @@ exports[`ChipGroup chip group with category and tooltip 1`] = `
169167
data-ouia-component-id="OUIA-Generated-Chip-9"
170168
data-ouia-component-type="PF4/Chip"
171169
data-ouia-safe="true"
172-
tooltipposition="top"
173170
>
174171
<span
175172
class="pf-c-chip__text"
@@ -241,7 +238,6 @@ exports[`ChipGroup chip group with closable category 1`] = `
241238
data-ouia-component-id="OUIA-Generated-Chip-3"
242239
data-ouia-component-type="PF4/Chip"
243240
data-ouia-safe="true"
244-
tooltipposition="top"
245241
>
246242
<span
247243
class="pf-c-chip__text"

packages/react-core/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,6 @@ exports[`typeahead multi select renders selected successfully 1`] = `
18591859
data-ouia-component-id="OUIA-Generated-Chip-1"
18601860
data-ouia-component-type="PF4/Chip"
18611861
data-ouia-safe="true"
1862-
tooltipposition="top"
18631862
>
18641863
<span
18651864
class="pf-c-chip__text"
@@ -1902,7 +1901,6 @@ exports[`typeahead multi select renders selected successfully 1`] = `
19021901
data-ouia-component-id="OUIA-Generated-Chip-2"
19031902
data-ouia-component-type="PF4/Chip"
19041903
data-ouia-safe="true"
1905-
tooltipposition="top"
19061904
>
19071905
<span
19081906
class="pf-c-chip__text"

packages/react-core/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
297297
data-ouia-component-id="OUIA-Generated-Chip-1"
298298
data-ouia-component-type="PF4/Chip"
299299
data-ouia-safe="true"
300-
tooltipposition="top"
301300
>
302301
<span
303302
class="pf-c-chip__text"
@@ -340,7 +339,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
340339
data-ouia-component-id="OUIA-Generated-Chip-2"
341340
data-ouia-component-type="PF4/Chip"
342341
data-ouia-safe="true"
343-
tooltipposition="top"
344342
>
345343
<span
346344
class="pf-c-chip__text"

0 commit comments

Comments
 (0)