Skip to content
Merged
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
42 changes: 42 additions & 0 deletions src/components/events/partials/modals/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import ButtonLikeAnchor from "../../../shared/ButtonLikeAnchor";
import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig";
import { unwrapResult } from "@reduxjs/toolkit";
import { ParseKeys } from "i18next";
import { useHotkeys } from "react-hotkeys-hook";
import { availableHotkeys } from "../../../../configs/hotkeysConfig";

export enum EventDetailsPage {
Metadata,
Expand Down Expand Up @@ -228,6 +230,46 @@ const EventDetails = ({
dispatch(openModalTab(tabNr, "workflow-details", "entry"));
}
};
const wizardTabs = tabs.filter(tab =>
!tab.hidden && tab.page !== EventDetailsPage.Tobira && tab.page !== EventDetailsPage.Statistics,
Comment thread
Arnei marked this conversation as resolved.
Outdated
);

const goNextStep = () => {
const currentIndex = wizardTabs.findIndex(tab => tab.page === page);
if (currentIndex === -1) { return; } // not in wizard, do nothing
const nextIndex = currentIndex + 1;
if (nextIndex >= wizardTabs.length) { return; } // already at last step (Comments)
openTab(wizardTabs[nextIndex].page);
};

const goPrevStep = () => {
const currentIndex = wizardTabs.findIndex(tab => tab.page === page);
if (currentIndex <= 0) { return; }
openTab(wizardTabs[currentIndex - 1].page);
};
// NEXT STEP
useHotkeys(
availableHotkeys.general.NEXT_STEP.sequence,
event => {
const target = event.target as HTMLElement;
if (!["INPUT", "TEXTAREA"].includes(target.tagName)) {
Comment thread
Arnei marked this conversation as resolved.
Outdated
goNextStep();
}
},
[goNextStep],
);

// PREVIOUS STEP
useHotkeys(
availableHotkeys.general.PREVIOUS_STEP.sequence,
event => {
const target = event.target as HTMLElement;
if (!["INPUT", "TEXTAREA"].includes(target.tagName)) {
goPrevStep();
}
},
[goPrevStep],
);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/modals/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const Modal = forwardRef<ModalHandle, PropsWithChildren<ModalProps>>(

return ReactDOM.createPortal(
isOpen &&
<FocusTrap>
<FocusTrap focusTrapOptions={{ escapeDeactivates: false }}>
Comment thread
Arnei marked this conversation as resolved.
Outdated
<div>
<div className="modal-animation modal-overlay" />
<section
Expand Down
15 changes: 13 additions & 2 deletions src/components/shared/modals/ModalContentTable.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRef } from "react";
import ModalContent from "./ModalContent";

/**
Expand All @@ -15,14 +16,24 @@ const ModalContentTable = ({
children: React.ReactNode
}) => {


// Store the last blurred/focused element
const lastFocusedRef = useRef<HTMLElement | null>(null);
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
const active = document.activeElement as HTMLElement | null;
if (event.key === "Escape") {
if (active && event.currentTarget.contains(active)) {
lastFocusedRef.current = active; // store the last focused element
active.blur();
}
}
};
Comment thread
Arnei marked this conversation as resolved.
Outdated
return (
<ModalContent
modalContentChildren={modalContentChildren}
modalContentClassName={modalContentClassName}
>
{modalBodyChildren}
<div className="full-col">
<div className="full-col" onKeyDown={handleKeyDown}>
{children}
</div>
</ModalContent>
Expand Down
10 changes: 10 additions & 0 deletions src/configs/hotkeysConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ export const availableHotkeys: HotkeyMapType = {
action: 'keyup',
allowIn: ['INPUT', 'SELECT', 'TEXTAREA']
},*/
NEXT_STEP: {
name: "next_step",
description: "HOTKEYS.DESCRIPTIONS.GENERAL.NEXT_STEP",
sequence: ["alt+enter"], // Alt + Enter moves forward
},
PREVIOUS_STEP: {
name: "previous_step",
description: "HOTKEYS.DESCRIPTIONS.GENERAL.PREVIOUS_STEP",
sequence: ["alt+backspace"], // Alt + Backspace moves backward
},
REMOVE_FILTERS: {
name: "remove_filters",
description: "HOTKEYS.DESCRIPTIONS.GENERAL.REMOVE_FILTERS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,8 @@
"SERIES_VIEW": "Series",
"NEW_EVENT": "Add event",
"NEW_SERIES": "Add series",
"NEXT_STEP": "Go to next step",
Comment thread
EnsiyehE marked this conversation as resolved.
Outdated
"PREVIOUS_STEP": "Go to previous step",
"CHEAT_SHEET": "Keyboard shortcuts",
"CLOSE_MODAL": "Close dialog"
}
Expand Down