Skip to content

[major] Reimplement Chip component #2431

Open
PelayoFelgueroso wants to merge 11 commits intomasterfrom
PelayoFelgueroso/chip-redesign
Open

[major] Reimplement Chip component #2431
PelayoFelgueroso wants to merge 11 commits intomasterfrom
PelayoFelgueroso/chip-redesign

Conversation

@PelayoFelgueroso
Copy link
Collaborator

@PelayoFelgueroso PelayoFelgueroso commented Mar 13, 2026

Checklist
(Check off all the items before submitting)

  • Build process is done without errors. All tests pass in the /lib directory.
  • Self-reviewed the code before submitting.
  • Meets accessibility standards.
  • Added/updated documentation to /website as needed.
  • Added/updated tests as needed.

Purpose
Reimplement Chip component based on the new design

@Jialecl Jialecl self-requested a review March 17, 2026 08:14
@Jialecl Jialecl self-assigned this Mar 17, 2026
const { queryByRole } = render(<DxcChip label="Chip" prefix={{ color: "primary" }} size="small" />);
test("Chip doesn't render with avatar and without label", () => {
const { queryByRole } = render(<DxcChip prefix={{ color: "primary" }} />);
const avatar = queryByRole("img", { hidden: true });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the chip component have an img role?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, in this test we are checking that the Chip doesn't render when it doesn't have a label but has an avatar as prefix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the test should check that there is no chip and not that there is not an img role element.
Also I do not really see the point in this test since we cover this scenario already with typing, we are even receiving an error in test itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all the users are using typescript. But if you think it is better, I can remove this test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we are using typescript in our tests.

const onClick = jest.fn();
const { getByText, getByRole } = render(<DxcChip label="Chip" onClick={onClick} />);
expect(getByText("Chip")).toBeTruthy();
fireEvent.click(getByRole("button"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The priority should be to try to access by text before accessing by role.

<td>If true, the component will be disabled.</td>
<td>
<TableCode>false</TableCode>
Text to be placed on the chip. When using an avatar as prefix, the label is required to ensure proper
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also mandatory on dismissible mode.

Value of the <Code>tabindex</Code> attribute applied to both the component and the prefix and suffix icons
when a function is given.
Value of the <Code>tabindex</Code> attribute applied to the component when mode is{" "}
<Code>"selectable"</Code> and clear icon when mode is <Code>"dismissible"</Code>. when a function is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "when a function is given."

<ComponentHeading name="Chip" />
<DxcParagraph>
A chip is a compact element used to label, filter or represent pieces of information within an interface.
A chip is a compact element used to label, filter or, represent pieces of information within an interface.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comma should be before the or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants