From 3fd13bda671121ff1e38eea5b9fb313f3d07dfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Thu, 25 Mar 2021 11:52:09 +0100 Subject: [PATCH] fix(js): remove `window` references --- packages/autocomplete-js/src/autocomplete.ts | 2 +- packages/autocomplete-js/src/getPanelPlacementStyle.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/autocomplete-js/src/autocomplete.ts b/packages/autocomplete-js/src/autocomplete.ts index 7dc5003bd..112e37028 100644 --- a/packages/autocomplete-js/src/autocomplete.ts +++ b/packages/autocomplete-js/src/autocomplete.ts @@ -281,7 +281,7 @@ export function autocomplete( toggleModalClassname(event.matches); } - const isModalDetachedMql = window.matchMedia( + const isModalDetachedMql = props.value.core.environment.matchMedia( getComputedStyle( props.value.core.environment.document.documentElement ).getPropertyValue('--aa-detached-modal-media-query') diff --git a/packages/autocomplete-js/src/getPanelPlacementStyle.ts b/packages/autocomplete-js/src/getPanelPlacementStyle.ts index 56a75611c..40516636e 100644 --- a/packages/autocomplete-js/src/getPanelPlacementStyle.ts +++ b/packages/autocomplete-js/src/getPanelPlacementStyle.ts @@ -1,7 +1,7 @@ import { AutocompleteOptions } from './types'; type GetPanelPlacementStyleParams = Pick< - AutocompleteOptions, + Required>, 'panelPlacement' | 'environment' > & { container: HTMLElement; @@ -12,7 +12,7 @@ export function getPanelPlacementStyle({ panelPlacement, container, form, - environment = window, + environment, }: GetPanelPlacementStyleParams) { const containerRect = container.getBoundingClientRect(); const top = container.offsetTop + containerRect.height;