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

Datepicker Error on focus #226

Open
thomas4Bitcraft opened this issue Sep 13, 2021 · 3 comments
Open

Datepicker Error on focus #226

thomas4Bitcraft opened this issue Sep 13, 2021 · 3 comments

Comments

@thomas4Bitcraft
Copy link

There is an error when trying to manually type in the date:

TypeError: Cannot read properties of undefined (reading 'focus')
    at VueComponent.focusTimePicker (t-datepicker.js?0e0b:4180)
    at keydown (t-datepicker.js?0e0b:4455)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1863)
    at Proxy.invoker (vue.runtime.esm.js?2b0e:2188)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1863)
    at Proxy.Vue.$emit (vue.runtime.esm.js?2b0e:3903)
    at keydown (t-datepicker.js?0e0b:1514)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1863)
    at HTMLInputElement.invoker (vue.runtime.esm.js?2b0e:2188)
    at HTMLInputElement.original._wrapper (vue.runtime.esm.js?2b0e:6961)

Here is my component:

<t-datepicker
        v-model="userData.birthday"
        :placeholder="$t('user.birthday')"
        name="birthday"
        class="w-full"
        userFormat="d.m.Y"
        dateFormat="Y-m-d"
        initialDate="2000-01-01"
        initialView="year"
        :maxDate="new Date()"
        :clearable="false"
        :timepicker="false"
      />

Anybody already had this issue and is there maybe a workaround?

@thomas4Bitcraft
Copy link
Author

Really nobody?

@hjJunior
Copy link

I can reproduce it, seems to happen when you press a key

@kal
Copy link

kal commented Jun 6, 2022

I have the same error I think. It looks like the cause is this line:

(this.$refs.timePicker as TimePicker).focus();

If you have no timepicker then $refs.timePicker is null leading to the error. A simple fix would be to change the line to

      (this.$refs.timePicker as TimePicker)?.focus();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants