Skip to content

Commit 5b26ff7

Browse files
authored
Feature Add next/previous tab hotkeys (#1447)
Feature Add next/previous tab hotkeys
1 parent b54c934 commit 5b26ff7

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

src/components/events/partials/modals/EventDetails.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig";
5050
import { unwrapResult } from "@reduxjs/toolkit";
5151
import { ParseKeys } from "i18next";
5252
import EventDetailsWorkflowSchedulingTab from "../ModalTabsAndPages/EventDetailsWorkflowSchedulingTab";
53+
import { useHotkeys } from "react-hotkeys-hook";
54+
import { availableHotkeys } from "../../../../configs/hotkeysConfig";
5355

5456
export enum EventDetailsPage {
5557
Metadata,
@@ -229,6 +231,42 @@ const EventDetails = ({
229231
dispatch(openModalTab(tabNr, "workflow-details", "entry"));
230232
}
231233
};
234+
const wizardTabs = tabs.filter(tab =>
235+
!tab.hidden,
236+
);
237+
238+
const goNextStep = () => {
239+
const currentIndex = wizardTabs.findIndex(tab => tab.page === page);
240+
if (currentIndex === -1) { return; } // not in wizard, do nothing
241+
const nextIndex = currentIndex + 1;
242+
if (nextIndex >= wizardTabs.length) { return; } // already at last step (Comments)
243+
openTab(wizardTabs[nextIndex].page);
244+
};
245+
246+
const goPrevStep = () => {
247+
const currentIndex = wizardTabs.findIndex(tab => tab.page === page);
248+
if (currentIndex <= 0) { return; }
249+
openTab(wizardTabs[currentIndex - 1].page);
250+
};
251+
// NEXT STEP
252+
useHotkeys(
253+
availableHotkeys.general.NEXT_PANEL.sequence,
254+
() => {
255+
goNextStep();
256+
},
257+
{ enableOnFormTags: ["INPUT", "TEXTAREA"] },
258+
[goNextStep],
259+
);
260+
261+
// PREVIOUS STEP
262+
useHotkeys(
263+
availableHotkeys.general.PREVIOUS_PANEL.sequence,
264+
() => {
265+
goPrevStep();
266+
},
267+
{ enableOnFormTags: ["INPUT", "TEXTAREA"] },
268+
[goPrevStep],
269+
);
232270

233271
return (
234272
<>

src/components/shared/modals/ModalContentTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ const ModalContentTable = ({
1414
modalBodyChildren?: React.ReactNode
1515
children: React.ReactNode
1616
}) => {
17-
18-
1917
return (
2018
<ModalContent
2119
modalContentChildren={modalContentChildren}

src/configs/hotkeysConfig.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ export const availableHotkeys: HotkeyMapType = {
5959
action: 'keyup',
6060
allowIn: ['INPUT', 'SELECT', 'TEXTAREA']
6161
},*/
62+
NEXT_PANEL: {
63+
name: "next_step",
64+
description: "HOTKEYS.DESCRIPTIONS.GENERAL.NEXT_PANEL",
65+
sequence: ["alt+enter"], // Alt + Enter moves forward
66+
},
67+
PREVIOUS_PANEL: {
68+
name: "previous_step",
69+
description: "HOTKEYS.DESCRIPTIONS.GENERAL.PREVIOUS_PANEL",
70+
sequence: ["alt+backspace"], // Alt + Backspace moves backward
71+
},
6272
REMOVE_FILTERS: {
6373
name: "remove_filters",
6474
description: "HOTKEYS.DESCRIPTIONS.GENERAL.REMOVE_FILTERS",

src/i18n/org/opencastproject/adminui/languages/lang-en_US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,8 @@
20872087
"SERIES_VIEW": "Series",
20882088
"NEW_EVENT": "Add event",
20892089
"NEW_SERIES": "Add series",
2090+
"NEXT_PANEL": "Go to next pane",
2091+
"PREVIOUS_PANEL": "Go to previous pane",
20902092
"CHEAT_SHEET": "Keyboard shortcuts",
20912093
"CLOSE_MODAL": "Close dialog"
20922094
}

0 commit comments

Comments
 (0)