ankurk91 / vue-flatpickr-component

Vue.js component for Flatpickr datetime picker :calendar:
https://ankurk91.github.io/vue-flatpickr-component/
MIT License
967 stars 101 forks source link

How to work with label. ID is not attached to input. #127

Closed michaelpumo closed 2 years ago

michaelpumo commented 5 years ago

I'm submitting a ...

[ ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[X] Other, please describe

Tell about your platform

Current behavior Unsure if this is a bug per se but I am trying to use a HTML label element for accessibility reasons. However, attaching an ID attribute to <flat-pickr id="hello" /> results in the ID being applied to the hidden field and NOT the generated input tag. This breaks the accessibility and the ability to focus the element with a label.

Expected behavior I would expect attributes added to the <flat-pickr /> element to bind to the visible / readable input that is generated in the DOM.

Minimal reproduction of the problem with instructions

<label for="hello">I am a label</label>
<flat-pickr id="hello" />
ankurk91 commented 5 years ago

Are you using altInput in your flatpickr config?

ankurk91 commented 5 years ago

This is a known issue, Similar https://github.com/ankurk91/vue-flatpickr-component/issues/104

michaelpumo commented 5 years ago

Hello @ankurk91 I am using the altInput option as you say:

Config:

config: {
  static: true,
  altFormat: 'J F Y',
  altInput: true,
  minDate: 'today',
  maxDate: new Date().fp_incr(365),
  disableMobile: true,
  disable: [
    (date) => {
      return (date.getDay() === 6 || date.getDay() === 0)
    },
    '2019-12-25',
    '2020-01-01',
    '2020-12-25',
    '2021-01-01'
  ]
}

The thing is, if I apply a class attribute to the calendar then that works just fine. It seems to only be the ID attribute that stays on the hidden element.

leads commented 4 years ago

I am now coming across this issue. There should be a label for the select and for the year input

michaelpumo commented 4 years ago

I believe this is actually an issue with Vue.js itself.

leads commented 4 years ago

I don't think it is Vue. It is flatpickr itself.

tmorehouse commented 4 years ago

From my testing, FlatPicker is not A11Y friendly (no screen reader announcements, keyboard accessibility is not at all presnet)