Skip to content

[EuiCheckableCard] onChange handler invoked twice upon checkbox click #8782

@tonyghiani

Description

@tonyghiani

Describe the bug
When the EuiCheckableCard component is set with the checkableType="checkbox" property, the handler passed to onChange is invoked twice when the click occurs directly on the checkbox itself, while it triggers correctly only once when clicking around the checkbox or on the label.

onChange triggered once

Image

onChange triggered twice

Image

Environment and versions

  • EUI version: 103
  • React version: 18

To Reproduce

Run this component in isolation

export default () => {
  const [checkbox, setCheckbox] = useState(false);
  const checkboxCardId = useGeneratedHtmlId({ prefix: 'checkboxCard' });

  return (
    <EuiCheckableCard
      id={checkboxCardId}
      label="I am a checkbox"
      checkableType="checkbox"
      value="checkbox1"
      checked={checkbox}
      onChange={() => setCheckbox(prev => !prev)}
    />
  );
};

N.B. Differently from the demo in the docs, the boolean update is made with a functional update to demonstrate how this could easily break depending on what the event handler does.

Expected behavior
The event handler passed to onChange should always be invoked once, indipendently from where the click occurs in the card.

Screenshots (Optional)

Screen.Recording.2025-06-11.at.14.33.49.mov

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions