Skip to content

Commit

Permalink
Fix run input blur only when value changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WiXSL committed Dec 20, 2021
1 parent 9febf1f commit 078c4e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ export const AutocompleteInput = (props: AutocompleteInputProps) => {
? inputText(getChoiceText(selectedItem).props.record)
: getChoiceText(selectedItem)
);

inputEl.current.blur();
}, [
input.value,
handleFilterChange,
Expand All @@ -333,6 +331,10 @@ export const AutocompleteInput = (props: AutocompleteInputProps) => {
inputText,
]);

useEffect(() => {
inputEl.current.blur();
}, [input.value]);

// This function ensures that the suggestion list stay aligned to the
// input element even if it moves (because user scrolled for example)
const updateAnchorEl = () => {
Expand Down

0 comments on commit 078c4e4

Please sign in to comment.