Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fuselage): Handle onBlur prop on AutoComplete #1222

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading