Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VAppBar): fix inability to scroll to the bottom #19921

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ describe('VAppBar', () => {
.get('.v-app-bar').should('not.be.visible')
})

it('should hide correctly when scroll to the bottom', () => {
cy.mount(({ scrollBehavior }: any) => (
<VLayout>
<VAppBar scrollBehavior={ scrollBehavior } />

<VMain style="min-height: 300px">
{
Array.from({ length: 7 }, () => (
<div class="pa-16 ma-2 w-50 bg-green text-center">
box
</div>
))
}
</VMain>
</VLayout>
))
.setProps({ scrollBehavior: 'hide' })
.get('.v-app-bar').should('be.visible')
.window().scrollTo('bottom')
.get('.v-app-bar').should('not.be.visible')
})

it('collapses', () => {
cy.mount(({ scrollBehavior }: any) => (
<VLayout>
Expand Down
7 changes: 7 additions & 0 deletions packages/vuetify/src/composables/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function useScroll (
) {
const { canScroll } = args
let previousScroll = 0
let previousScrollHeight = 0
const target = ref<Element | Window | null>(null)
const currentScroll = shallowRef(0)
const savedScroll = shallowRef(0)
Expand Down Expand Up @@ -71,6 +72,12 @@ export function useScroll (
previousScroll = currentScroll.value
currentScroll.value = ('window' in targetEl) ? targetEl.pageYOffset : targetEl.scrollTop

const currentScrollHeight = targetEl instanceof Window ? document.documentElement.scrollHeight : targetEl.scrollHeight
if (previousScrollHeight !== currentScrollHeight) {
previousScrollHeight = currentScrollHeight
return
}

isScrollingUp.value = currentScroll.value < previousScroll
currentThreshold.value = Math.abs(currentScroll.value - scrollThreshold.value)
}
Expand Down
Loading