From e0f1638c0b5b974b0e846d3b672454a10396c555 Mon Sep 17 00:00:00 2001 From: literat Date: Fri, 5 Jan 2024 16:07:29 +0100 Subject: [PATCH] Fix(web-react): Closing Modal by Escape key * `cancel` event was not fired while closing dialog using escape key --- packages/web-react/src/hooks/useCancelEvent.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/web-react/src/hooks/useCancelEvent.ts b/packages/web-react/src/hooks/useCancelEvent.ts index 95e99616fc..c3e796951d 100644 --- a/packages/web-react/src/hooks/useCancelEvent.ts +++ b/packages/web-react/src/hooks/useCancelEvent.ts @@ -1,6 +1,12 @@ -import { useCallback, useEffect, MutableRefObject } from 'react'; - -const EVENT_CANCEL = 'cancel'; +import { MutableRefObject, useCallback, useEffect } from 'react'; + +/** + * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/cancel_event + * @see https://jira.lmc.cz/browse/DS-1108 + * Here should be used `cancel` event instead of `close` event. + * But when dialog is closed using `escape` key, `cancel` event is not fired. + */ +const EVENT_CANCEL = 'close'; export const useCancelEvent = (ref: MutableRefObject, callback: (event: Event) => void) => { const handleCancel = useCallback(