Skip to content

Scroll into date picker view on open #35

@sampullman

Description

@sampullman

In the previous version of this widget (i.e. the last version of vue3-date-time-picker), we were able to automatically scroll the page to get the whole datepicker on the screen by doing something like this:

<template>
  <Datepicker
    :id="dateId"
    @open="opened"
  />
</template>

<script lang="ts" setup>
const uid = '1'
const dateId = `datepicker-${uid}`

const opened = async () => {
  await nextTick()
  document.getElementById(dateId)?.scrollIntoView()
}
</script>

After updating to this package, the same thing doesn't work. The best workaround we've found so far is:

<template>
  <Datepicker
    :uid="uid"
    :transitions="false"
    @open="opened"
  />
</template>

<script lang="ts" setup>
const uid = '1'
const dateId = `dp-menu-${uid}`

const opened = () => {
  setTimeout(() => {
    document.getElementById(dateId)?.scrollIntoView()
  }, 200)
}
</script>

Describe the solution you'd like
It would be great if the original solution could work. Maybe I've missed something though and there's a better way to do this 😅

Describe alternatives you've considered
The alternative is in the above description

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions