Skip to content

Commit

Permalink
fix: ModalPicker button onClick propagation
Browse files Browse the repository at this point in the history
When the button in ModalPicker components is clicked, the event is
propagated, causing parent elements onClick to trigger as well.

Added event stopPropagation to ModalPicker components.
  • Loading branch information
Gido Manders committed Feb 7, 2024
1 parent 46c1912 commit 6cdc4b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/form/ModalPicker/multiple/ModalPickerMultiple.tsx
Expand Up @@ -178,6 +178,7 @@ export function ModalPickerMultiple<T>(props: Props<T>) {

const openModal: MouseEventHandler<HTMLButtonElement> = (event) => {
event.preventDefault();
event.stopPropagation();

// Always copy the `value` so the `selected` is a fresh array.
// Otherwise, the selection will be the same as the value, which
Expand Down
1 change: 1 addition & 0 deletions src/form/ModalPicker/single/ModalPickerSingle.tsx
Expand Up @@ -171,6 +171,7 @@ export function ModalPickerSingle<T>(props: Props<T>) {

const openModal: MouseEventHandler<HTMLButtonElement> = (event) => {
event.preventDefault();
event.stopPropagation();
setIsOpen(true);
setSelected(value);
setQuery('');
Expand Down

0 comments on commit 6cdc4b9

Please sign in to comment.