@@ -112,6 +112,7 @@ export function autocomplete<TItem extends BaseItem>(
112
112
autocomplete : autocomplete . value ,
113
113
autocompleteScopeApi,
114
114
classNames : props . value . renderer . classNames ,
115
+ environment : props . value . core . environment ,
115
116
isDetached : isDetached . value ,
116
117
placeholder : props . value . core . placeholder ,
117
118
propGetters,
@@ -237,7 +238,7 @@ export function autocomplete<TItem extends BaseItem>(
237
238
// We scroll to the top of the panel whenever the query changes (i.e. new
238
239
// results come in) so that users don't have to.
239
240
if ( state . query !== prevState . query ) {
240
- const scrollablePanels = document . querySelectorAll (
241
+ const scrollablePanels = props . value . core . environment . document . querySelectorAll (
241
242
'.aa-Panel--scrollable'
242
243
) ;
243
244
scrollablePanels . forEach ( ( scrollablePanel ) => {
@@ -336,19 +337,27 @@ export function autocomplete<TItem extends BaseItem>(
336
337
337
338
function setIsModalOpen ( value : boolean ) {
338
339
requestAnimationFrame ( ( ) => {
339
- const prevValue = document . body . contains ( dom . value . detachedOverlay ) ;
340
+ const prevValue = props . value . core . environment . document . body . contains (
341
+ dom . value . detachedOverlay
342
+ ) ;
340
343
341
344
if ( value === prevValue ) {
342
345
return ;
343
346
}
344
347
345
348
if ( value ) {
346
- document . body . appendChild ( dom . value . detachedOverlay ) ;
347
- document . body . classList . add ( 'aa-Detached' ) ;
349
+ props . value . core . environment . document . body . appendChild (
350
+ dom . value . detachedOverlay
351
+ ) ;
352
+ props . value . core . environment . document . body . classList . add ( 'aa-Detached' ) ;
348
353
dom . value . input . focus ( ) ;
349
354
} else {
350
- document . body . removeChild ( dom . value . detachedOverlay ) ;
351
- document . body . classList . remove ( 'aa-Detached' ) ;
355
+ props . value . core . environment . document . body . removeChild (
356
+ dom . value . detachedOverlay
357
+ ) ;
358
+ props . value . core . environment . document . body . classList . remove (
359
+ 'aa-Detached'
360
+ ) ;
352
361
autocomplete . value . setQuery ( '' ) ;
353
362
autocomplete . value . refresh ( ) ;
354
363
}
0 commit comments