@@ -19,6 +19,7 @@ import useRect from '../../hooks/useRect';
1919import isDirectQueryEnabled from './utils/is-direct-query' ;
2020import getContainerPadding from './assets/list-sizes/container-padding' ;
2121import ListBoxHeader from './components/ListBoxHeader' ;
22+ import ListBoxFocusBorder from './ListBoxFocusBorder' ;
2223
2324const PREFIX = 'ListBoxInline' ;
2425const classes = {
@@ -28,8 +29,8 @@ const classes = {
2829} ;
2930
3031const StyledGrid = styled ( Grid , {
31- shouldForwardProp : ( p ) => ! [ 'containerPadding' , 'isGridMode' , ' styles'] . includes ( p ) ,
32- } ) ( ( { theme , containerPadding, isGridMode , styles } ) => ( {
32+ shouldForwardProp : ( p ) => ! [ 'containerPadding' , 'styles' ] . includes ( p ) ,
33+ } ) ( ( { containerPadding, styles } ) => ( {
3334 ...styles . background , // sets background color and image of listbox
3435 [ `& .${ classes . listBoxHeader } ` ] : {
3536 alignSelf : 'center' ,
@@ -44,12 +45,6 @@ const StyledGrid = styled(Grid, {
4445 [ `& .${ classes . listboxWrapper } ` ] : {
4546 padding : containerPadding ,
4647 } ,
47- '&:focus' : {
48- boxShadow : `inset 0 0 0 2px ${ theme . palette . custom . focusBorder } !important` ,
49- } ,
50- '&:focus ::-webkit-scrollbar-track' : {
51- boxShadow : ! isGridMode ? 'inset -2px -2px 0px #3F8AB3' : undefined ,
52- } ,
5348 '&:focus-visible' : {
5449 outline : 'none' ,
5550 } ,
@@ -94,7 +89,7 @@ function ListBoxInline({ options, layout }) {
9489
9590 const containerRef = useRef ( ) ;
9691 const searchInputRef = useRef ( ) ;
97- const [ containerRectRef , containerRect ] = useRect ( ) ;
92+ const [ containerRectRef , containerRect , containerNode ] = useRect ( ) ;
9893 const [ showToolbar , setShowToolbar ] = useState ( false ) ;
9994 const [ showSearch , setShowSearch ] = useState ( false ) ;
10095 const hovering = useRef ( false ) ;
@@ -107,6 +102,11 @@ function ListBoxInline({ options, layout }) {
107102 const isModalMode = useCallback ( ( ) => isModal ( { app, appSelections } ) , [ app , appSelections ] ) ;
108103 const isInvalid = layout ?. qListObject . qDimensionInfo . qError ;
109104 const errorText = isInvalid && constraints . active ? 'Visualization.Invalid.Dimension' : 'Visualization.Incomplete' ;
105+ const [ , setHasFocus ] = useState ( false ) ; // Force render on focus change to show/hide ListBoxFocusBorder
106+ const [ listboxChildNode , setListboxChildNode ] = useState ( null ) ;
107+ const listboxChildRef = useCallback ( ( node ) => {
108+ setListboxChildNode ( node ) ;
109+ } , [ ] ) ;
110110
111111 const { handleKeyDown, handleOnMouseEnter, handleOnMouseLeave, globalKeyDown } = useMemo (
112112 ( ) =>
@@ -272,11 +272,19 @@ function ListBoxInline({ options, layout }) {
272272 onMouseLeave = { handleOnMouseLeave }
273273 ref = { ( el ) => {
274274 containerRef . current = el ;
275- containerRectRef ( el ) ;
275+ containerRectRef ?. ( el ) ;
276276 } }
277- isGridMode = { isGridMode }
278277 aria-label = { keyboard . active ? translator . get ( 'Listbox.ScreenReaderInstructions' ) : '' }
278+ onFocus = { ( ) => setHasFocus ( true ) }
279+ onBlur = { ( ) => setHasFocus ( false ) }
279280 >
281+ < ListBoxFocusBorder
282+ width = { containerRect ?. width }
283+ height = { containerRect ?. height }
284+ isModalMode = { isModalMode ( ) }
285+ childNode = { listboxChildNode }
286+ containerNode = { containerNode }
287+ />
280288 { showAttachedToolbar && listBoxHeader }
281289 < Grid
282290 item
@@ -286,6 +294,7 @@ function ListBoxInline({ options, layout }) {
286294 minHeight = { listBoxMinHeight }
287295 role = "region"
288296 aria-label = { translator . get ( 'Listbox.ResultFilterLabel' ) }
297+ ref = { listboxChildRef }
289298 >
290299 < Grid item >
291300 < ListBoxSearch
0 commit comments