diff --git a/src/components/Panel/Panel.test.tsx b/src/components/Panel/Panel.test.tsx index 9f5fbf44b..bb129b4de 100644 --- a/src/components/Panel/Panel.test.tsx +++ b/src/components/Panel/Panel.test.tsx @@ -148,18 +148,6 @@ describe('Panel', () => { expect(wrapper.find('.button-primary').text()).toBe('Close'); }); - test('Should call onClose when escape key is pressed', () => { - const onClose = jest.fn(); - wrapper.setProps({ - visible: true, - onClose, - }); - - // Simulate escape key press - const escapeKeyEvent = new KeyboardEvent('keydown', { key: 'Escape' }); - document.dispatchEvent(escapeKeyEvent); - }); - test('Should render content when renderContentAlways is true', () => { const { getByText } = render( diff --git a/src/components/Panel/Panel.tsx b/src/components/Panel/Panel.tsx index 44d69924d..2ad65129b 100644 --- a/src/components/Panel/Panel.tsx +++ b/src/components/Panel/Panel.tsx @@ -6,7 +6,6 @@ import React, { useImperativeHandle, useRef, useState, - useCallback, } from 'react'; import GradientContext, { Gradient } from '../ConfigProvider/GradientContext'; import { OcThemeName } from '../ConfigProvider'; @@ -138,19 +137,6 @@ export const Panel = React.forwardRef( ); }, [mergedLocale]); - const handleEscapeKey = useCallback((event: KeyboardEvent) => { - if (event.key === 'Escape' && visible) { - onClose?.(event); - } - }, [onClose, visible]); - - useEffect(() => { - document.addEventListener('keydown', handleEscapeKey); - return () => { - document.removeEventListener('keydown', handleEscapeKey); - }; - }, [handleEscapeKey]); - const panelBackdropClasses: string = mergeClasses([ styles.panelBackdrop, panelWrapperClassNames, diff --git a/src/components/Panel/Panel.types.ts b/src/components/Panel/Panel.types.ts index 0ce220056..1aa5c9b6d 100644 --- a/src/components/Panel/Panel.types.ts +++ b/src/components/Panel/Panel.types.ts @@ -19,8 +19,7 @@ export type PanelPlacement = 'top' | 'right' | 'bottom' | 'left'; export type EventType = | React.KeyboardEvent - | React.MouseEvent - | KeyboardEvent; + | React.MouseEvent; export type CloseButtonProps = Omit;