mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
This commit is contained in:
parent
14cc053094
commit
88271bf1a7
@ -1,3 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import { useEffect, useState, useRef, useCallback } from 'react';
|
||||
import { isInsideContainer } from '@joplin/lib/dom';
|
||||
|
||||
@ -40,8 +41,7 @@ export default (props: Props) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
const onKeyDown = useCallback((event: any) => {
|
||||
const onKeyDown = useCallback((event: KeyboardEvent|React.KeyboardEvent) => {
|
||||
// Early exit if it's neither ENTER nor ESCAPE, because isInSubModal
|
||||
// function can be costly.
|
||||
if (event.keyCode !== 13 && event.keyCode !== 27) return;
|
||||
@ -49,8 +49,12 @@ export default (props: Props) => {
|
||||
if (!isTopDialog() || isInSubModal(event.target)) return;
|
||||
|
||||
if (event.keyCode === 13) {
|
||||
if (event.target.nodeName !== 'TEXTAREA') {
|
||||
props.onOkButtonClick();
|
||||
if ('nodeName' in event.target && event.target.nodeName === 'INPUT') {
|
||||
const target = event.target as HTMLInputElement;
|
||||
|
||||
if (target.type !== 'button' && target.type !== 'checkbox') {
|
||||
props.onOkButtonClick();
|
||||
}
|
||||
}
|
||||
} else if (event.keyCode === 27) {
|
||||
props.onCancelButtonClick();
|
||||
|
Loading…
Reference in New Issue
Block a user