Prevent Up and Down keys being overriden by MUI listeners when not in use (#698)
This commit is contained in:
parent
53155bd7d6
commit
83378174b7
1 changed files with 21 additions and 0 deletions
|
@ -323,6 +323,27 @@ 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
|
||||
React.useEffect(() => {
|
||||
const inputElement = inputRef && inputRef.current;
|
||||
|
||||
function overrideKeyHandling(event) {
|
||||
if (!suggestionTerm) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
if (inputElement) {
|
||||
inputElement.addEventListener('keydown', overrideKeyHandling);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (inputElement) {
|
||||
inputElement.removeEventListener('keydown', overrideKeyHandling);
|
||||
}
|
||||
};
|
||||
}, [inputRef, suggestionTerm]);
|
||||
|
||||
/** ------ **/
|
||||
/** Render **/
|
||||
/** ------ **/
|
||||
|
|
Loading…
Reference in a new issue