Skip to content

Commit

Permalink
fix(fuselage): Handle onBlur prop on AutoComplete (#1222)
Browse files Browse the repository at this point in the history
Co-authored-by: Tasso Evangelista <[email protected]>
  • Loading branch information
yash-rajpal and tassoevan authored Nov 16, 2023
1 parent c09ef5b commit ab9e4bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-planets-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/fuselage": patch
---

Handle `onBlur` prop on AutoComplete
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

yarn update-readme
yarn lint-staged
yarn lint-staged --allow-empty
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export function AutoComplete({
error,
disabled,
multiple,
onBlur: onBlurAction = () => {},
...props
}: AutoCompleteProps): ReactElement {
const ref = useRef();
Expand Down Expand Up @@ -121,6 +122,11 @@ export function AutoComplete({
const [cursor, handleKeyDown, , reset, [optionsAreVisible, hide, show]] =
useCursor(value, memoizedOptions, handleSelect);

const handleOnBlur = useMutableCallback((event) => {
hide();
onBlurAction(event);
});

useEffect(reset, [filter]);

return (
Expand Down Expand Up @@ -148,7 +154,7 @@ export function AutoComplete({
onChange={useMutableCallback((e) =>
setFilter(e.currentTarget.value)
)}
onBlur={hide}
onBlur={handleOnBlur}
onFocus={show}
onKeyDown={handleKeyDown}
placeholder={
Expand Down

0 comments on commit ab9e4bf

Please sign in to comment.