Skip to content

Commit 6960f9e

Browse files
committed
fix: ensure body is scrollable after esc to exit dialog
1 parent 02386f7 commit 6960f9e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/components/Search.astro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const { trailingSlashes = false } = Astro.props
8888
#openBtn: HTMLButtonElement | null
8989
#controller: AbortController
9090
trailingSlashes: boolean
91+
stripTrailingSlash: (path: string) => string
92+
formatURL: (path: string) => string
9193

9294
constructor() {
9395
super()
@@ -120,6 +122,8 @@ const { trailingSlashes = false } = Astro.props
120122
if (this.#dialog) {
121123
this.#dialog.addEventListener('close', () => {
122124
window.removeEventListener('click', this.onWindowClick)
125+
const body = document.querySelector('body')
126+
body?.classList.remove('overflow-hidden')
123127
})
124128
} else {
125129
console.warn('Dialog not found')
@@ -184,8 +188,6 @@ const { trailingSlashes = false } = Astro.props
184188
}
185189

186190
closeModal = () => {
187-
const body = document.querySelector('body')
188-
body?.classList.remove('overflow-hidden')
189191
this.#dialog?.close()
190192
}
191193

src/components/SelectTheme.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ function kebabToTitleCase(str: string): string {
9191
if (this.#dialog) {
9292
this.#dialog.addEventListener('close', () => {
9393
window.removeEventListener('click', this.onWindowClick)
94+
const body = document.querySelector('body')
95+
body?.classList.remove('overflow-hidden')
9496
})
9597
} else {
9698
console.warn('Dialog not found')
@@ -137,8 +139,6 @@ function kebabToTitleCase(str: string): string {
137139
}
138140

139141
closeModal = () => {
140-
const body = document.querySelector('body')
141-
body?.classList.remove('overflow-hidden')
142142
this.#dialog?.close()
143143
}
144144

0 commit comments

Comments
 (0)