1- import { isInteractive , isTransparent , isWritableElement } from "../../utils" ;
1+ import { isTransparent } from "../../utils" ;
22import { ExcalidrawElement } from "../../element/types" ;
33import { AppState } from "../../types" ;
44import { TopPicks } from "./TopPicks" ;
@@ -14,9 +14,9 @@ import { ColorTuple, COLOR_PALETTE, ColorPaletteCustom } from "../../colors";
1414import PickerHeading from "./PickerHeading" ;
1515import { t } from "../../i18n" ;
1616import clsx from "clsx" ;
17+ import { useRef } from "react" ;
1718import { jotaiScope } from "../../jotai" ;
1819import { ColorInput } from "./ColorInput" ;
19- import { useRef } from "react" ;
2020import { activeEyeDropperAtom } from "../EyeDropper" ;
2121import { PropertiesPopover } from "../PropertiesPopover" ;
2222import { useExcalidrawContainer } from "../App" ;
@@ -95,6 +95,7 @@ const ColorPickerPopupContent = ({
9595 />
9696 </ div >
9797 ) ;
98+
9899 const popoverRef = useRef < HTMLDivElement > ( null ) ;
99100
100101 const focusPickerContent = ( ) => {
@@ -108,6 +109,7 @@ const ColorPickerPopupContent = ({
108109 container = { container }
109110 style = { { maxWidth : "208px" } }
110111 onFocusOutside = { ( event ) => {
112+ // refocus due to eye dropper
111113 focusPickerContent ( ) ;
112114 event . preventDefault ( ) ;
113115 } }
@@ -119,18 +121,7 @@ const ColorPickerPopupContent = ({
119121 event . preventDefault ( ) ;
120122 }
121123 } }
122- onCloseAutoFocus = { ( e ) => {
123- e . stopPropagation ( ) ;
124- // prevents focusing the trigger
125- e . preventDefault ( ) ;
126-
127- // return focus to excalidraw container unless
128- // user focuses an interactive element, such as a button, or
129- // enters the text editor by clicking on canvas with the text tool
130- if ( container && ! isInteractive ( document . activeElement ) ) {
131- container . focus ( ) ;
132- }
133-
124+ onClose = { ( ) => {
134125 updateData ( { openPopup : null } ) ;
135126 setActiveColorPickerSection ( null ) ;
136127 } }
@@ -166,8 +157,6 @@ const ColorPickerPopupContent = ({
166157 onEscape = { ( event ) => {
167158 if ( eyeDropperState ) {
168159 setEyeDropperState ( null ) ;
169- } else if ( isWritableElement ( event . target ) ) {
170- focusPickerContent ( ) ;
171160 } else {
172161 updateData ( { openPopup : null } ) ;
173162 }
@@ -198,7 +187,7 @@ const ColorPickerTrigger = ({
198187 return (
199188 < Popover . Trigger
200189 type = "button"
201- className = { clsx ( "color-picker__button active-color" , {
190+ className = { clsx ( "color-picker__button active-color properties-trigger " , {
202191 "is-transparent" : color === "transparent" || ! color ,
203192 } ) }
204193 aria-label = { label }
0 commit comments