Refactor login (#748)

* wip refactor login

* wip refactor login

* Fix lint conflicts

* Complete Sign In only

* Feature complete

* Fix test

* Fix test
This commit is contained in:
Charles Bochet
2023-07-21 22:05:45 -07:00
committed by GitHub
parent 725a46adfa
commit 775b4c353d
49 changed files with 758 additions and 764 deletions

View File

@ -20,6 +20,7 @@ type OwnProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
label?: string;
onChange?: (text: string) => void;
fullWidth?: boolean;
disableHotkeys?: boolean;
error?: string;
};
@ -104,6 +105,7 @@ export function TextInput({
error,
required,
type,
disableHotkeys = false,
...props
}: OwnProps): JSX.Element {
const theme = useTheme();
@ -117,16 +119,20 @@ export function TextInput({
const handleFocus: FocusEventHandler<HTMLInputElement> = (e) => {
onFocus?.(e);
setHotkeyScopeAndMemorizePreviousScope(InputHotkeyScope.TextInput);
if (!disableHotkeys) {
setHotkeyScopeAndMemorizePreviousScope(InputHotkeyScope.TextInput);
}
};
const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {
onBlur?.(e);
goBackToPreviousHotkeyScope();
if (!disableHotkeys) {
goBackToPreviousHotkeyScope();
}
};
useScopedHotkeys(
[Key.Enter, Key.Escape],
[Key.Escape, Key.Enter],
() => {
inputRef.current?.blur();
},