Skip to content

Commit

Permalink
Fixed ActionableNotification with closeOnEscape prop (#17433)
Browse files Browse the repository at this point in the history
* chore(release): v11.66.0 (#17413)

Co-authored-by: tay1orjones <[email protected]>
Co-authored-by: Taylor Jones <[email protected]>

* fix: fixed onKeyDown

---------

Co-authored-by: carbon-automation[bot] <103539138+carbon-automation[bot]@users.noreply.github.com>
Co-authored-by: tay1orjones <[email protected]>
Co-authored-by: Taylor Jones <[email protected]>
Co-authored-by: kennylam <[email protected]>
  • Loading branch information
5 people committed Sep 14, 2024
1 parent 47ceaad commit 06844e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/react/src/components/Notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ function useEscapeToClose(ref, callback, override = true) {
};

useIsomorphicEffect(() => {
document.addEventListener('keydown', handleKeyDown, false);
if (ref.current !== null) {
document.addEventListener('keydown', handleKeyDown, false);
}

return () => document.removeEventListener('keydown', handleKeyDown, false);
});
}
Expand Down

0 comments on commit 06844e9

Please sign in to comment.