diff --git a/src/components/ui/ConfirmDialog.tsx b/src/components/ui/ConfirmDialog.tsx index b2f276121..872de02b4 100644 --- a/src/components/ui/ConfirmDialog.tsx +++ b/src/components/ui/ConfirmDialog.tsx @@ -1,7 +1,8 @@ -import React, { FC, memo } from '../../lib/teact/teact'; +import React, { FC, memo, useCallback, useRef } from '../../lib/teact/teact'; import useLang from '../../hooks/useLang'; import { TextPart } from '../common/helpers/renderMessageText'; +import useKeyboardListNavigation from '../../hooks/useKeyboardListNavigation'; import Modal from './Modal'; import Button from './Button'; @@ -37,6 +38,15 @@ const ConfirmDialog: FC = ({ }) => { const lang = useLang(); + // eslint-disable-next-line no-null/no-null + const containerRef = useRef(null); + + const handleSelectWithEnter = useCallback((index: number) => { + if (index === -1) confirmHandler(); + }, [confirmHandler]); + + const handleKeyDown = useKeyboardListNavigation(containerRef, isOpen, handleSelectWithEnter, '.Button'); + return ( = ({ isOpen={isOpen} onClose={onClose} onCloseAnimationEnd={onCloseAnimationEnd} - onEnter={confirmHandler} > {text && text.split('\\n').map((textPart) => (

{textPart}

))} {textParts || children} -
+