浏览代码

fix: color picker keyboard handling not working (#6464)

David Luzar 2 年之前
父节点
当前提交
034113772d
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/components/Popover.tsx

+ 7 - 1
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) {