Skip to content

Commit

Permalink
fix(Chip): spread fewer props (#8584)
Browse files Browse the repository at this point in the history
* fix(Chip): spread fewer props

* fix snapshots
  • Loading branch information
nicolethoen authored Jan 23, 2023
1 parent 91180fe commit b43a524
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
42 changes: 36 additions & 6 deletions packages/react-core/src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,34 @@ export class Chip extends React.Component<ChipProps, ChipState> {
});

renderOverflowChip = () => {
const { children, className, onClick, ouiaId, ...props } = this.props;
const Component = this.props.component as any;
const {
children,
className,
onClick,
ouiaId,
textMaxWidth,
style,
component,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
tooltipPosition,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
isOverflowChip,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
closeBtnAriaLabel,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
isReadOnly,
...props
} = this.props;
const Component = component as any;
return (
<Component
onClick={onClick}
{...(this.props.textMaxWidth && {
{...(textMaxWidth && {
style: this.setChipStyle(),
...this.props.style
...style
})}
className={css(styles.chip, styles.modifiers.overflow, className)}
{...(this.props.component === 'button' ? { type: 'button' } : {})}
{...(component === 'button' ? { type: 'button' } : {})}
{...getOUIAProps('OverflowChip', ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
{...props}
>
Expand All @@ -103,7 +120,20 @@ export class Chip extends React.Component<ChipProps, ChipState> {
};

renderInnerChip(id: string) {
const { children, className, onClick, closeBtnAriaLabel, isReadOnly, component, ouiaId, ...props } = this.props;
const {
children,
className,
onClick,
closeBtnAriaLabel,
isReadOnly,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
isOverflowChip,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
tooltipPosition,
component,
ouiaId,
...props
} = this.props;
const Component = component as any;
return (
<Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`Chip closable 1`] = `
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
id="chip_one"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -53,7 +52,6 @@ exports[`Chip closable with tooltip 1`] = `
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
id="chip_one"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -99,7 +97,6 @@ exports[`Chip custom max-width text 1`] = `
data-ouia-safe="true"
style="--pf-c-chip__text--MaxWidth: 100px;"
textmaxwidth="100px"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -140,12 +137,9 @@ exports[`Chip overflow 1`] = `
<DocumentFragment>
<div
class="pf-c-chip pf-m-overflow my-chp-cls"
closebtnarialabel="close"
component="div"
data-ouia-component-id="OUIA-Generated-Chip-1"
data-ouia-component-type="PF4/OverflowChip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand All @@ -163,7 +157,6 @@ exports[`Chip readonly 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-4"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand All @@ -183,7 +176,6 @@ exports[`Chip with role='gridcell' 1`] = `
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
role="gridcell"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ exports[`ChipGroup chip group default 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-1"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -97,7 +96,6 @@ exports[`ChipGroup chip group with category 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-2"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -169,7 +167,6 @@ exports[`ChipGroup chip group with category and tooltip 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-9"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -241,7 +238,6 @@ exports[`ChipGroup chip group with closable category 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-3"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,6 @@ exports[`typeahead multi select renders selected successfully 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-1"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -1902,7 +1901,6 @@ exports[`typeahead multi select renders selected successfully 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-2"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-1"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down Expand Up @@ -340,7 +339,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
data-ouia-component-id="OUIA-Generated-Chip-2"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
Expand Down

0 comments on commit b43a524

Please sign in to comment.