File tree Expand file tree Collapse file tree 4 files changed +33
-8
lines changed Expand file tree Collapse file tree 4 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ import { PropTypes } from "prop-types";
21
21
import Box from "../Box" ;
22
22
import {
23
23
getFloatingUiRootElement ,
24
- getFloatingUiZIndex
24
+ getFloatingUiZIndex ,
25
+ isRenderedInReactSelectMenu
25
26
} from "../../utils/floatingUiHelpers" ;
26
27
27
28
const DIRECTIONS_MAP = {
@@ -359,6 +360,7 @@ export default function Popover({
359
360
{ text }
360
361
</ StyledPopover >
361
362
) ;
363
+ const containsLinks = refs . floating ?. current ?. querySelectorAll ( "a" ) . length ;
362
364
363
365
return (
364
366
< Box { ...props } aria-describedby = { context . floatingId } >
@@ -368,9 +370,19 @@ export default function Popover({
368
370
root = { getFloatingUiRootElement ( context . refs . reference ) }
369
371
preserveTabOrder = { true }
370
372
>
371
- < FloatingFocusManager context = { context } modal = { false } >
372
- { Popover }
373
- </ FloatingFocusManager >
373
+ { containsLinks ? (
374
+ < FloatingFocusManager
375
+ context = { context }
376
+ modal = { false }
377
+ initialFocus = {
378
+ isRenderedInReactSelectMenu ( context . refs . reference ) && - 1
379
+ }
380
+ >
381
+ { Popover }
382
+ </ FloatingFocusManager >
383
+ ) : (
384
+ Popover
385
+ ) }
374
386
</ FloatingPortal >
375
387
) : (
376
388
Popover
Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ const getFloatingUiZIndex = (triggerRef) => {
12
12
return 900 ;
13
13
} ;
14
14
15
+ const REACT_SELECT_MENU = "react-select-menu" ;
16
+
17
+ const isRenderedInReactSelectMenu = ( triggerRef ) =>
18
+ document . getElementById ( REACT_SELECT_MENU ) ?. contains ?. ( triggerRef . current ) ;
19
+
15
20
const getFloatingUiRootElement = ( triggerRef ) => {
16
21
const activeModalRef = document . getElementById ( "modal-overlay" ) ;
17
22
@@ -21,7 +26,15 @@ const getFloatingUiRootElement = (triggerRef) => {
21
26
return document . getElementById ( "modal" ) ;
22
27
}
23
28
29
+ if ( isRenderedInReactSelectMenu ( triggerRef ) ) {
30
+ return document . getElementById ( REACT_SELECT_MENU ) . firstChild ;
31
+ }
32
+
24
33
return undefined ;
25
34
} ;
26
35
27
- export { getFloatingUiZIndex , getFloatingUiRootElement } ;
36
+ export {
37
+ getFloatingUiZIndex ,
38
+ getFloatingUiRootElement ,
39
+ isRenderedInReactSelectMenu
40
+ } ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " orcs-design-system" ,
3
- "version" : " 3.2.33 " ,
3
+ "version" : " 3.2.34 " ,
4
4
"engines" : {
5
5
"node" : " 20.12.2"
6
6
},
You can’t perform that action at this time.
0 commit comments