diff --git a/apps/client/src/common/utils/keyEvent.ts b/apps/client/src/common/utils/keyEvent.ts index 30bf3c6e1..aa8e18e94 100644 --- a/apps/client/src/common/utils/keyEvent.ts +++ b/apps/client/src/common/utils/keyEvent.ts @@ -7,3 +7,11 @@ export function isKeyEnter(event: KeyboardEvent): boolean { export function isKeyEscape(event: KeyboardEvent): boolean { return event.key === 'Escape'; } + +export function preventEscape(event: KeyboardEvent, callback?: () => void): void { + if (isKeyEscape(event)) { + event.preventDefault(); + event.stopPropagation(); + callback?.(); + } +} diff --git a/apps/client/src/features/app-settings/panel/integrations-panel/OscIntegrations.tsx b/apps/client/src/features/app-settings/panel/integrations-panel/OscIntegrations.tsx index d124a2313..b23583685 100644 --- a/apps/client/src/features/app-settings/panel/integrations-panel/OscIntegrations.tsx +++ b/apps/client/src/features/app-settings/panel/integrations-panel/OscIntegrations.tsx @@ -8,7 +8,7 @@ import { generateId } from 'ontime-utils'; import { maybeAxiosError } from '../../../../common/api/utils'; import useOscSettings, { useOscSettingsMutation } from '../../../../common/hooks-query/useOscSettings'; -import { isKeyEscape } from '../../../../common/utils/keyEvent'; +import { preventEscape } from '../../../../common/utils/keyEvent'; import { isASCII, isASCIIorEmpty, isIPAddress, isOnlyNumbers, startsWithSlash } from '../../../../common/utils/regex'; import { isOntimeCloud } from '../../../../externals'; import * as Panel from '../../panel-utils/PanelUtils'; @@ -63,13 +63,6 @@ export default function OscIntegrations() { } }; - const preventEscape = (event: React.KeyboardEvent) => { - if (isKeyEscape(event)) { - event.preventDefault(); - event.stopPropagation(); - } - }; - const handleAddNewSubscription = () => { prepend({ id: generateId(),