Skip to content

Commit

Permalink
fix: handle double clicks with stopPropogation
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed Feb 5, 2024
1 parent 66be949 commit eb7c382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/blade/src/components/Input/BaseInput/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,7 @@ const _BaseInput: React.ForwardRefRenderFunction<BladeElementRef, BaseInputProps
handleOnSubmit={handleOnSubmit}
handleOnInput={handleOnInput}
handleOnKeyDown={handleOnKeyDown}
// In DropdownTrigger, click is handled on BaseInputTagSlot to cover padding around the real input
handleOnClick={isDropdownTrigger ? undefined : handleOnClick}
handleOnClick={handleOnClick}
leadingIcon={leadingIcon}
prefix={prefix}
interactionElement={interactionElement}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ const _StyledBaseInput: React.ForwardRefRenderFunction<
name={name}
type="button"
onClick={(event: React.MouseEvent<HTMLInputElement>): void => {
if (props.isDropdownTrigger) {
// dropdown triggers have click event on outer container as well on web to handle outer padding clicks of input
// we don't want the clicks to be called twice in such cases so we stop propogation if this click has happened
event.stopPropagation();
}

handleOnClick?.({ name, value: event });
}}
{...commonProps}
Expand Down Expand Up @@ -169,6 +175,12 @@ const _StyledBaseInput: React.ForwardRefRenderFunction<
handleOnInput?.({ name, value: event });
}}
onClick={(event) => {
if (props.isDropdownTrigger) {
// dropdown triggers have click event on outer container as well on web to handle outer padding clicks of input
// we don't want the clicks to be called twice in such cases so we stop propogation if this click has happened
event.stopPropagation();
}

handleOnClick?.({ name, value: event });
}}
autoCapitalize={autoCapitalize}
Expand Down

0 comments on commit eb7c382

Please sign in to comment.