@@ -10,33 +10,10 @@ import './CommandPaletteSearchBar.scss';
1010export function CommandPaletteSearchBar ( { slot } : { slot ?: string } ) {
1111 const { t } = useTranslation ( ) ;
1212 const [ open , setOpen ] = useState ( false ) ;
13- const inputRef = useRef < InputDomRef | null > ( null ) ;
14- const commandPaletteRef = useRef < HTMLDivElement | null > ( null ) ;
1513 const [ resourceCache , updateResourceCache ] = useObjectState <
1614 Record < string , K8sResource [ ] >
1715 > ( ) ;
1816
19- useEffect ( ( ) => {
20- if ( ! open || ! inputRef . current || ! commandPaletteRef . current ) return ;
21-
22- const shellbarRect = inputRef . current . getBoundingClientRect ( ) ;
23- const paletteContent = commandPaletteRef . current . querySelector (
24- '.command-palette-ui__content' ,
25- ) as HTMLElement ;
26-
27- if ( ! paletteContent ) return ;
28-
29- const paletteWrapper = commandPaletteRef . current . querySelector (
30- '.command-palette-ui__wrapper' ,
31- ) as HTMLElement ;
32-
33- if ( paletteWrapper && window . screen . width > 1040 ) {
34- paletteWrapper . style . left = `${ shellbarRect . left +
35- shellbarRect . width / 2 -
36- paletteContent . offsetWidth / 2 } px`;
37- }
38- } , [ open ] ) ;
39-
4017 const setShowDialog = ( value : boolean ) => {
4118 const modalPresent = document . querySelector ( 'ui5-dialog[open]' ) ;
4219 // disable opening palette if other modal is present
@@ -48,6 +25,7 @@ export function CommandPaletteSearchBar({ slot }: { slot?: string }) {
4825 return (
4926 < >
5027 < Input
28+ id = "command-palette-search-bar"
5129 accessibleName = "command-palette-search-bar"
5230 onClick = { ( ) => setOpen ( true ) }
5331 onInput = { e => e . preventDefault ( ) }
@@ -56,18 +34,15 @@ export function CommandPaletteSearchBar({ slot }: { slot?: string }) {
5634 icon = { < Icon name = "slim-arrow-right" /> }
5735 slot = { slot }
5836 placeholder = { t ( 'command-palette.search.quick-navigation' ) }
59- ref = { inputRef }
6037 />
6138 { open &&
6239 createPortal (
63- < div ref = { commandPaletteRef } >
64- < CommandPaletteUI
65- showCommandPalette = { open }
66- hide = { ( ) => setShowDialog ( false ) }
67- resourceCache = { resourceCache }
68- updateResourceCache = { updateResourceCache }
69- />
70- </ div > ,
40+ < CommandPaletteUI
41+ showCommandPalette = { open }
42+ hide = { ( ) => setShowDialog ( false ) }
43+ resourceCache = { resourceCache }
44+ updateResourceCache = { updateResourceCache }
45+ /> ,
7146 document . body ,
7247 ) }
7348 </ >
0 commit comments