Skip to content

Commit

Permalink
[fields] Support Backspace key on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Feb 6, 2023
1 parent a25e098 commit 554ca1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ export const useField = <
return () => window.clearTimeout(focusTimeoutRef.current);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

React.useEffect(() => {
if (state.tempValueStrAndroid != null && selectedSectionIndexes != null) {
clearActiveSection();
}
}, [state.tempValueStrAndroid]); // eslint-disable-line react-hooks/exhaustive-deps

const valueStr = React.useMemo(
() => state.tempValueStrAndroid ?? fieldValueManager.getValueStrFromSections(state.sections),
[state.sections, fieldValueManager, state.tempValueStrAndroid],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const useFieldState = <
return setState((prevState) => ({
...prevState,
sections: newSections,
tempValueStrAndroid: null,
...newValue,
}));
};
Expand Down

0 comments on commit 554ca1e

Please sign in to comment.