We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f77a73 commit 1885625Copy full SHA for 1885625
1 file changed
src/Preview/index.tsx
@@ -332,19 +332,20 @@ const Preview: React.FC<PreviewProps> = props => {
332
if (open) {
333
const { keyCode } = event;
334
335
- if (keyCode === KeyCode.ESC) {
336
- event.preventDefault();
337
- onClose?.();
338
- }
339
-
340
- if (showLeftOrRightSwitches) {
341
- if (keyCode === KeyCode.LEFT) {
+ switch (keyCode) {
+ case KeyCode.ESC:
342
event.preventDefault();
343
- onActive(-1);
344
- } else if (keyCode === KeyCode.RIGHT) {
345
346
- onActive(1);
347
+ onClose?.();
+ break;
+ case KeyCode.LEFT:
+ case KeyCode.RIGHT:
+ if (showLeftOrRightSwitches) {
+ event.preventDefault();
+ onActive(keyCode === KeyCode.LEFT ? -1 : 1);
+ }
+ default:
348
349
}
350
351
});
0 commit comments