mirror of
https://github.com/RGBCube/cinny
synced 2025-07-30 16:37:46 +00:00
Fix editor focus after autocomplete (#2233)
* upgrade slatejs * collapse autocomplete on escape * make FN_KEYS_REGEX const in module scope
This commit is contained in:
parent
2c7038cd1f
commit
ccfe30cd68
4 changed files with 84 additions and 49 deletions
|
@ -353,10 +353,14 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||
}
|
||||
if (isKeyHotkey('escape', evt)) {
|
||||
evt.preventDefault();
|
||||
if (autocompleteQuery) {
|
||||
setAutocompleteQuery(undefined);
|
||||
return;
|
||||
}
|
||||
setReplyDraft(undefined);
|
||||
}
|
||||
},
|
||||
[submit, setReplyDraft, enterForNewline]
|
||||
[submit, setReplyDraft, enterForNewline, autocompleteQuery]
|
||||
);
|
||||
|
||||
const handleKeyUp: KeyboardEventHandler = useCallback(
|
||||
|
|
|
@ -20,6 +20,7 @@ import { useKeyDown } from '../../hooks/useKeyDown';
|
|||
import { editableActiveElement } from '../../utils/dom';
|
||||
import navigation from '../../../client/state/navigation';
|
||||
|
||||
const FN_KEYS_REGEX = /^F\d+$/;
|
||||
const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
||||
const { code } = evt;
|
||||
if (evt.metaKey || evt.altKey || evt.ctrlKey) {
|
||||
|
@ -27,7 +28,7 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
|||
}
|
||||
|
||||
// do not focus on F keys
|
||||
if (/^F\d+$/.test(code)) return false;
|
||||
if (FN_KEYS_REGEX.test(code)) return false;
|
||||
|
||||
// do not focus on numlock/scroll lock
|
||||
if (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue