Closed
Labels
good first issue⚠️ needs validationFor bugs that need confirmation as to whether they're reproducible
Description
The following (copied from the sandbox demo for EuiButtonGroup) fires 2 onChange events for each click.
const [toggleIdSelected, setToggleIdSelected] = useState(`${idPrefix}1`);
const onChange = (optionId) => {
setToggleIdSelected(optionId);
console.log(optionId);
};
return (
<Fragment>
<EuiButtonGroup
legend="This is a basic group"
options={toggleButtons}
idSelected={toggleIdSelected}
onChange={(id) => onChange(id)}
/>
</Fragment>
);
Possibly related, if the setToggleIdSelected(optionId) line is removed, 3 events will fire per click.
Metadata
Metadata
Assignees
Labels
good first issue⚠️ needs validationFor bugs that need confirmation as to whether they're reproducible
Activity
PhaedrusTheGreek commentedon Jul 26, 2021
I noticed that the onChange event is being fired when calling
setToggleIdSelected. A few days later I was playing with the EUISearchBar component and found that it does not fire an event when itsqueryproperty changes, instead the user is responsible for calling change manually.