fix: Keyboard handlers should not be considered while composing

This commit is contained in:
Tom Moor
2023-07-04 11:28:05 -04:00
parent 29db1ef1bf
commit e6e9512979
4 changed files with 19 additions and 1 deletions

View File

@@ -20,6 +20,10 @@ function ArrowKeyNavigation(
const handleKeyDown = React.useCallback( const handleKeyDown = React.useCallback(
(ev) => { (ev) => {
if (onEscape) { if (onEscape) {
if (ev.nativeEvent.isComposing) {
return;
}
if (ev.key === "Escape") { if (ev.key === "Escape") {
onEscape(ev); onEscape(ev);
} }

View File

@@ -45,6 +45,10 @@ function InputSearchPage({
const handleKeyDown = React.useCallback( const handleKeyDown = React.useCallback(
(ev: React.KeyboardEvent<HTMLInputElement>) => { (ev: React.KeyboardEvent<HTMLInputElement>) => {
if (ev.nativeEvent.isComposing) {
return;
}
if (ev.key === "Enter") { if (ev.key === "Enter") {
ev.preventDefault(); ev.preventDefault();
history.push( history.push(

View File

@@ -88,10 +88,14 @@ function SearchPopover({ shareId }: Props) {
const handleSearchInputFocus = React.useCallback(() => { const handleSearchInputFocus = React.useCallback(() => {
focusRef.current = searchInputRef.current; focusRef.current = searchInputRef.current;
}, []); }, [searchInputRef]);
const handleKeyDown = React.useCallback( const handleKeyDown = React.useCallback(
(ev: React.KeyboardEvent<HTMLInputElement>) => { (ev: React.KeyboardEvent<HTMLInputElement>) => {
if (ev.nativeEvent.isComposing) {
return;
}
if (ev.key === "Enter") { if (ev.key === "Enter") {
if (searchResults) { if (searchResults) {
popover.show(); popover.show();

View File

@@ -260,6 +260,9 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
const handleLinkInputKeydown = ( const handleLinkInputKeydown = (
event: React.KeyboardEvent<HTMLInputElement> event: React.KeyboardEvent<HTMLInputElement>
) => { ) => {
if (event.nativeEvent.isComposing) {
return;
}
if (!props.isActive) { if (!props.isActive) {
return; return;
} }
@@ -441,6 +444,9 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
}; };
const handleKeyDown = (event: KeyboardEvent) => { const handleKeyDown = (event: KeyboardEvent) => {
if (event.isComposing) {
return;
}
if (!props.isActive) { if (!props.isActive) {
return; return;
} }