Skip to content

Commit

Permalink
fix(inputsearch): add onchange events for the new inputClear icon
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudmanson committed Sep 21, 2023
1 parent 0197fed commit d1dcf20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/components/src/core/Autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ const Autocomplete = <

function clearInput() {
setInputValue("");
if (onInputChange)
onInputChange(
{ target: { value: "" } } as React.ChangeEvent<HTMLInputElement>,
"",
"clear"
);
}

function defaultGetOptionLabel(
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/core/InputSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const InputSearch = forwardRef<HTMLDivElement, InputSearchProps>(
const clearInput = () => {
setValue("");
setHasValue(false);

if (handleSubmit) handleSubmit("");

if (onChange) {
onChange({
target: { value: "" },
} as React.ChangeEvent<HTMLInputElement>);
}
};

const localHandleSubmit = () => {
Expand Down

0 comments on commit d1dcf20

Please sign in to comment.