Skip to content

Commit db0d325

Browse files
committed
fix: prevent key bindings if a dialog is open
1 parent bde3849 commit db0d325

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

frontend/testing-view/src/features/keyBindings/hooks/useGlobalKeyBindings.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const useGlobalKeyBindings = () => {
1818

1919
useEffect(() => {
2020
const handleKeyPress = (e: KeyboardEvent) => {
21+
// Skip if a dialog is open
22+
if (document.querySelector('[role="dialog"]')) return;
23+
2124
// Skip if user is typing in an input/textarea/contenteditable
2225
if (
2326
e.target instanceof HTMLInputElement ||
@@ -46,25 +49,16 @@ export const useGlobalKeyBindings = () => {
4649
bindings.forEach((binding) => {
4750
// Handle special built-in commands
4851
if (binding.commandId === START_LOGGER_COMMAND_ID) {
49-
logger.testingView.log(
50-
`Executing Start Logger via key binding [${key}]`,
51-
);
5252
startLogging();
5353
return;
5454
}
5555

5656
if (binding.commandId === STOP_LOGGER_COMMAND_ID) {
57-
logger.testingView.log(
58-
`Executing Stop Logger via key binding [${key}]`,
59-
);
6057
stopLogging();
6158
return;
6259
}
6360

6461
if (binding.commandId === TOGGLE_LOGGER_COMMAND_ID) {
65-
logger.testingView.log(
66-
`Executing Toggle Logger via key binding [${key}]`,
67-
);
6862
toggleLogging();
6963
return;
7064
}

frontend/testing-view/src/hooks/useLogger.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { socketService } from "@workspace/core";
1+
import { logger, socketService } from "@workspace/core";
22
import { useTopic } from "@workspace/ui/hooks";
33
import { useEffect, useState } from "react";
44
import { config } from "../../config";
55
import { useStore } from "../store/store";
6-
import type { BoardName } from "../types/data/board";
76
import type { LoggerStatus } from "../types/common/logger";
7+
import type { BoardName } from "../types/data/board";
88
import type { TelemetryCatalogItem } from "../types/data/telemetryCatalogItem";
99

1010
// Shared singleton state across all useLogger instances
@@ -24,7 +24,9 @@ export function useLogger() {
2424

2525
useEffect(() => {
2626
listeners.add(setStatus);
27-
return () => { listeners.delete(setStatus); };
27+
return () => {
28+
listeners.delete(setStatus);
29+
};
2830
}, []);
2931

3032
const log = (enable: boolean) => {
@@ -68,12 +70,14 @@ export function useLogger() {
6870
const startLogging = () => {
6971
if (sharedStatus === "recording" || sharedStatus === "loading") return;
7072
const vars = getVariables();
73+
logger.testingView.log("Starting logger...");
7174
socketService.post("logger/variables", vars);
7275
log(true);
7376
};
7477

7578
const stopLogging = () => {
7679
if (sharedStatus !== "recording") return;
80+
logger.testingView.log("Stopping logger...");
7781
log(false);
7882
};
7983

0 commit comments

Comments
 (0)