Skip to content

Commit

Permalink
fix(VDialog): allow nested elements to overflow scroll (#13548)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Bowman <bowman@swiftbunny.com>
  • Loading branch information
jonathanrbowman and Jonathan Bowman committed Jul 19, 2021
1 parent dc59b71 commit 24af61e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/vuetify/src/mixins/overlayable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,21 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
const style = window.getComputedStyle(el)
return ['auto', 'scroll'].includes(style.overflowY!) && el.scrollHeight > el.clientHeight
},
shouldScroll (el: Element, delta: number) {
if (el.scrollTop === 0 && delta < 0) return true
return el.scrollTop + el.clientHeight === el.scrollHeight && delta > 0
shouldScroll (el: Element, delta: number): boolean {
if (el.hasAttribute('data-app')) return false

const alreadyAtTop = el.scrollTop === 0
const alreadyAtBottom = el.scrollTop + el.clientHeight === el.scrollHeight
const scrollingUp = delta < 0
const scrollingDown = delta > 0

if (!alreadyAtTop && scrollingUp) return true
if (!alreadyAtBottom && scrollingDown) return true
if ((alreadyAtTop || alreadyAtBottom)) {
return this.shouldScroll(el.parentNode as Element, delta)
}

return false
},
isInside (el: Element, parent: Element): boolean {
if (el === parent) {
Expand All @@ -178,7 +190,7 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
// getSelection returns null in firefox in some edge cases, can be ignored
const selected = window.getSelection()!.anchorNode as Element
if (dialog && this.hasScrollbar(dialog) && this.isInside(selected, dialog)) {
return this.shouldScroll(dialog, delta)
return !this.shouldScroll(dialog, delta)
}
return true
}
Expand All @@ -190,7 +202,7 @@ export default Vue.extend<Vue & Toggleable & Stackable & options>().extend({
if (el === document.documentElement) return true
if (el === this.$refs.content) return true

if (this.hasScrollbar(el as Element)) return this.shouldScroll(el as Element, delta)
if (this.hasScrollbar(el as Element)) return !this.shouldScroll(el as Element, delta)
}

return true
Expand Down

0 comments on commit 24af61e

Please sign in to comment.