Skip to content

Commit 6273ace

Browse files
author
路振凯
committed
add isEditable
1 parent adf7f18 commit 6273ace

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Preview/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import CSSMotion from '@rc-component/motion';
22
import Portal, { type PortalProps } from '@rc-component/portal';
33
import { useEvent } from '@rc-component/util';
44
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
5+
import KeyCode from '@rc-component/util/lib/KeyCode';
56
import { clsx } from 'clsx';
67
import React, { useContext, useEffect, useRef, useState } from 'react';
78
import { PreviewGroupContext } from '../context';
@@ -328,15 +329,21 @@ const Preview: React.FC<PreviewProps> = props => {
328329

329330
// >>>>> Effect: Keyboard
330331
const onKeyDown = useEvent((event: KeyboardEvent) => {
331-
if (open) {
332-
if (showLeftOrRightSwitches) {
333-
if (event.key === 'ArrowLeft') {
334-
onActive(-1);
335-
event.preventDefault();
336-
} else if (event.key === 'ArrowRight') {
337-
onActive(1);
338-
event.preventDefault();
339-
}
332+
if (!open) {
333+
return;
334+
}
335+
336+
if (KeyCode.isEditableTarget(event)) {
337+
return;
338+
}
339+
340+
if (showLeftOrRightSwitches) {
341+
if (event.key === 'ArrowLeft') {
342+
onActive(-1);
343+
event.preventDefault();
344+
} else if (event.key === 'ArrowRight') {
345+
onActive(1);
346+
event.preventDefault();
340347
}
341348
}
342349
});

0 commit comments

Comments
 (0)