Fix livestream key listeners (#702)

This commit is contained in:
saltrafael 2022-01-14 18:07:21 -03:00 committed by GitHub
parent ea9c7a4a27
commit a1a7ca321f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,6 +241,7 @@ export default function TextareaWithSuggestions(props: Props) {
isEmote,
});
} else if (suggestionValue) {
inputRef.current.removeAttribute('typing-term');
setSuggestionValue(null);
}
}
@ -323,12 +324,14 @@ export default function TextareaWithSuggestions(props: Props) {
return () => window.removeEventListener('keydown', handleKeyDown);
}, [handleSelect, highlightedSuggestion, suggestionTerm]);
// Prevent keyboard keys like Up and Down being overriden by MUI listeners when not in use
// Prevent keyboard keys Up and Down being overriden by MUI listeners when not in use
React.useEffect(() => {
const inputElement = inputRef && inputRef.current;
function overrideKeyHandling(event) {
if (!suggestionTerm) {
const { keyCode } = event;
if (!suggestionTerm && (keyCode === KEYCODES.UP || keyCode === KEYCODES.DOWN)) {
event.stopPropagation();
}
}