1
Fork 0
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:
Ajay Bura 2025-02-26 21:42:42 +11:00 committed by GitHub
parent 2c7038cd1f
commit ccfe30cd68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 84 additions and 49 deletions

View file

@ -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(

View file

@ -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 (