Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
return (
<Component
onClick={onClick}
{...this.props}
{...(this.props.textMaxWidth && {
style: this.setChipStyle(),
...this.props.style
Expand All @@ -106,6 +107,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
const Component = component as any;
return (
<Component
{...this.props}
{...(this.props.textMaxWidth && {
style: this.setChipStyle()
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ describe('Chip', () => {
);
expect(asFragment()).toMatchSnapshot();
});

test("with role='gridcell'", () => {
const { asFragment } = render(
<Chip className="my-chp-cls" role="gridcell">
I'm a roled chip
</Chip>
);
expect(asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ exports[`Chip closable 1`] = `
<DocumentFragment>
<div
class="pf-c-chip my-chp-cls"
closebtnarialabel="close"
component="div"
data-ouia-component-id="OUIA-Generated-Chip-2"
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 @@ -47,9 +51,13 @@ exports[`Chip closable with tooltip 1`] = `
<DocumentFragment>
<div
class="pf-c-chip my-chp-cls"
closebtnarialabel="close"
component="div"
data-ouia-component-id="OUIA-Generated-Chip-3"
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 @@ -90,10 +98,14 @@ exports[`Chip custom max-width text 1`] = `
<DocumentFragment>
<div
class="pf-c-chip my-chp-cls"
closebtnarialabel="close"
component="div"
data-ouia-component-id="OUIA-Generated-Chip-5"
data-ouia-component-type="PF4/Chip"
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 @@ -134,9 +146,12 @@ 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 @@ -151,9 +166,12 @@ exports[`Chip readonly 1`] = `
<DocumentFragment>
<div
class="pf-c-chip my-chp-cls"
closebtnarialabel="close"
component="div"
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 @@ -164,3 +182,50 @@ exports[`Chip readonly 1`] = `
</div>
</DocumentFragment>
`;

exports[`Chip with role='gridcell' 1`] = `
<DocumentFragment>
<div
class="pf-c-chip my-chp-cls"
closebtnarialabel="close"
component="div"
data-ouia-component-id="OUIA-Generated-Chip-6"
data-ouia-component-type="PF4/Chip"
data-ouia-safe="true"
role="gridcell"
tooltipposition="top"
>
<span
class="pf-c-chip__text"
id="pf-random-id-5"
>
I'm a roled chip
</span>
<button
aria-disabled="false"
aria-label="close"
aria-labelledby="remove_pf-random-id-5 pf-random-id-5"
class="pf-c-button pf-m-plain"
data-ouia-component-id="close"
data-ouia-component-type="PF4/Button"
data-ouia-safe="true"
id="remove_pf-random-id-5"
type="button"
>
<svg
aria-hidden="true"
fill="currentColor"
height="1em"
role="img"
style="vertical-align: -0.125em;"
viewBox="0 0 352 512"
width="1em"
>
<path
d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
/>
</svg>
</button>
</div>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ exports[`ChipGroup chip group default 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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 @@ -93,9 +96,12 @@ exports[`ChipGroup chip group with category 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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 @@ -164,9 +170,12 @@ exports[`ChipGroup chip group with category and tooltip 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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 @@ -235,9 +244,12 @@ exports[`ChipGroup chip group with closable category 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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 @@ -1856,9 +1856,12 @@ exports[`typeahead multi select renders selected successfully 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="Remove"
component="div"
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 @@ -1898,9 +1901,12 @@ exports[`typeahead multi select renders selected successfully 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="Remove"
component="div"
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 @@ -294,9 +294,12 @@ exports[`Toolbar should render with custom chip content 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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 @@ -336,9 +339,12 @@ exports[`Toolbar should render with custom chip content 1`] = `
>
<div
class="pf-c-chip"
closebtnarialabel="close"
component="div"
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