From 034113772d80910b6e5335db946499d9135e46ce Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sun, 16 Apr 2023 15:33:30 +0200 Subject: [PATCH] fix: color picker keyboard handling not working (#6464) --- src/components/Popover.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Popover.tsx b/src/components/Popover.tsx index c1249f79..987e9fb9 100644 --- a/src/components/Popover.tsx +++ b/src/components/Popover.tsx @@ -36,7 +36,13 @@ export const Popover = ({ return; } - container.focus(); + // focus popover only if the caller didn't focus on something else nested + // within the popover, which should take precedence. Fixes cases + // like color picker listening to keydown events on containers nested + // in the popover. + if (!container.contains(document.activeElement)) { + container.focus(); + } const handleKeyDown = (event: KeyboardEvent) => { if (event.key === KEYS.TAB) {