diff --git a/packages/search-widget/src/search-modal.ts b/packages/search-widget/src/search-modal.ts index 20af20f..b0edb61 100644 --- a/packages/search-widget/src/search-modal.ts +++ b/packages/search-widget/src/search-modal.ts @@ -1,5 +1,5 @@ import resetStyles from '@unocss/reset/tailwind.css?inline'; -import { LitElement, css, html, unsafeCSS } from 'lit'; +import { LitElement, PropertyValues, css, html, unsafeCSS } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { styleMap } from 'lit/directives/style-map.js'; import { OverlayScrollbars } from 'overlayscrollbars'; @@ -38,6 +38,18 @@ export class SearchModal extends LitElement { }, 0); } + override willUpdate(changedProperties: PropertyValues) { + if (!changedProperties.has('open')) { + return; + } + + if (this.open) { + document.body.style.overflow = 'hidden'; + } else { + document.body.style.removeProperty('overflow'); + } + } + override render() { return html`