File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ const eventTypeMapping = {
33
33
touchend : 'onTouchEnd'
34
34
} ;
35
35
36
+ const reactMajorVersion = parseInt ( React . version . split ( '.' ) [ 0 ] , 10 ) ;
37
+
36
38
function useForkRef < T = any > (
37
39
...refs : Array < Ref < T > | undefined >
38
40
) : RefCallback < T > {
@@ -88,6 +90,10 @@ const ClickAwayListener: FunctionComponent<Props> = ({
88
90
node . current = ref ;
89
91
} , ( children as any ) . ref ) ;
90
92
93
+ const handleReact19ChildRef = ( instance : HTMLElement | null ) => {
94
+ node . current = instance ;
95
+ } ;
96
+
91
97
useEffect ( ( ) => {
92
98
const nodeDocument = node . current ?. ownerDocument ?? document ;
93
99
@@ -122,7 +128,7 @@ const ClickAwayListener: FunctionComponent<Props> = ({
122
128
123
129
return React . Children . only (
124
130
cloneElement ( children as ReactElement < any > , {
125
- ref : combinedRef ,
131
+ ref : reactMajorVersion >= 19 ? handleReact19ChildRef : combinedRef ,
126
132
[ mappedFocusEvent ] : handleBubbledEvents ( mappedFocusEvent ) ,
127
133
[ mappedMouseEvent ] : handleBubbledEvents ( mappedMouseEvent ) ,
128
134
[ mappedTouchEvent ] : handleBubbledEvents ( mappedTouchEvent )
You can’t perform that action at this time.
0 commit comments