@@ -113,16 +113,24 @@ export const useClickOutsideField = (
113113 childRef . current . focus ( ) ;
114114 }
115115
116- const handleBlur = ( e : FocusEvent ) => {
117- // Check if blur moves to an element outside childRef
118- if ( childRef . current && ! childRef . current . contains ( e . relatedTarget as Node ) ) {
119- setEditMode ( false ) ;
120- }
121- } ;
122-
123- if ( childRef . current ) {
124- childRef . current . addEventListener ( "blur" , handleBlur , true ) ; // capture phase
125- }
116+ /* TODO: Fix handleBlur
117+ This is supposed to handle blur for tab navigation, which it does.
118+ But it also triggers on mouse clicks that are inside the field, causing
119+ unintended blurs and sometimes other elements besides the input element
120+ to not work. A proper fix should properly set edit mode to false when the
121+ field is left via keyboard navigation, but not set edit mode to false when
122+ the user is clicking inside of the field.
123+ */
124+ // const handleBlur = (e: FocusEvent) => {
125+ // // Check if blur moves to an element outside childRef
126+ // if (childRef.current && !childRef.current.contains(e.relatedTarget as Node)) {
127+ // setEditMode(false);
128+ // }
129+ // };
130+
131+ // if (childRef.current) {
132+ // childRef.current.addEventListener("blur", handleBlur, true); // capture phase
133+ // }
126134
127135 // Adding event listener for detecting click outside
128136 window . addEventListener ( "mousedown" , handleClickOutside ) ;
0 commit comments