Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@rc-component/motion": "^1.0.0",
"@rc-component/portal": "^2.1.2",
"@rc-component/util": "^1.3.0",
"@rc-component/util": "^1.7.0",
"clsx": "^2.1.1"
},
"devDependencies": {
Expand Down
9 changes: 4 additions & 5 deletions src/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import CSSMotion from '@rc-component/motion';
import Portal, { type PortalProps } from '@rc-component/portal';
import { useEvent } from '@rc-component/util';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import KeyCode from '@rc-component/util/lib/KeyCode';
import { clsx } from 'clsx';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { PreviewGroupContext } from '../context';
Expand Down Expand Up @@ -330,13 +329,13 @@ const Preview: React.FC<PreviewProps> = props => {
// >>>>> Effect: Keyboard
const onKeyDown = useEvent((event: KeyboardEvent) => {
if (open) {
const { keyCode } = event;

if (showLeftOrRightSwitches) {
if (keyCode === KeyCode.LEFT) {
if (event.key === 'ArrowLeft') {
onActive(-1);
} else if (keyCode === KeyCode.RIGHT) {
event.preventDefault();
} else if (event.key === 'ArrowRight') {
onActive(1);
event.preventDefault();
}
}
}
Expand Down
Loading