Skip to content

Commit 24af61e

Browse files
jonathanrbowmanJonathan Bowman
and
Jonathan Bowman
authored
fix(VDialog): allow nested elements to overflow scroll (#13548)
Co-authored-by: Jonathan Bowman <[email protected]>
1 parent dc59b71 commit 24af61e

File tree

1 file changed

+17
-5
lines changed
  • packages/vuetify/src/mixins/overlayable

1 file changed

+17
-5
lines changed

Diff for: packages/vuetify/src/mixins/overlayable/index.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,21 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
156156
const style = window.getComputedStyle(el)
157157
return ['auto', 'scroll'].includes(style.overflowY!) && el.scrollHeight > el.clientHeight
158158
},
159-
shouldScroll (el: Element, delta: number) {
160-
if (el.scrollTop === 0 && delta < 0) return true
161-
return el.scrollTop + el.clientHeight === el.scrollHeight && delta > 0
159+
shouldScroll (el: Element, delta: number): boolean {
160+
if (el.hasAttribute('data-app')) return false
161+
162+
const alreadyAtTop = el.scrollTop === 0
163+
const alreadyAtBottom = el.scrollTop + el.clientHeight === el.scrollHeight
164+
const scrollingUp = delta < 0
165+
const scrollingDown = delta > 0
166+
167+
if (!alreadyAtTop && scrollingUp) return true
168+
if (!alreadyAtBottom && scrollingDown) return true
169+
if ((alreadyAtTop || alreadyAtBottom)) {
170+
return this.shouldScroll(el.parentNode as Element, delta)
171+
}
172+
173+
return false
162174
},
163175
isInside (el: Element, parent: Element): boolean {
164176
if (el === parent) {
@@ -178,7 +190,7 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
178190
// getSelection returns null in firefox in some edge cases, can be ignored
179191
const selected = window.getSelection()!.anchorNode as Element
180192
if (dialog && this.hasScrollbar(dialog) && this.isInside(selected, dialog)) {
181-
return this.shouldScroll(dialog, delta)
193+
return !this.shouldScroll(dialog, delta)
182194
}
183195
return true
184196
}
@@ -190,7 +202,7 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
190202
if (el === document.documentElement) return true
191203
if (el === this.$refs.content) return true
192204

193-
if (this.hasScrollbar(el as Element)) return this.shouldScroll(el as Element, delta)
205+
if (this.hasScrollbar(el as Element)) return !this.shouldScroll(el as Element, delta)
194206
}
195207

196208
return true

0 commit comments

Comments
 (0)