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

The id is missing on the the visibile input, unfortunately by default #57

Open
frederikhors opened this issue Apr 16, 2023 · 10 comments
Open
Labels
upstream Not actually an issue with this package

Comments

@frederikhors
Copy link
Contributor

I just found out that flatpickr doesn't copy the id on the visibile input, as described in this issue: flatpickr/flatpickr#1414.

This is really bad for accessibility and labels as you can imagine.

What do you think about adding an id prop on <FlatPickr> to handle this?

@frederikhors
Copy link
Contributor Author

@jacobmischka can you please do this?

@jacobmischka
Copy link
Owner

id (and all other props) should be passed through to the underlying element already:

image

The types should support this already as well.

I don't quite understand the issue, sorry.

@frederikhors
Copy link
Contributor Author

Sorry and thank you.

I should have specified right away that I'm using this code: https://svelte.dev/repl/8a4850fd71154b6594e1ce8d756d80f4?version=3.59.1.

@frederikhors
Copy link
Contributor Author

image

@christopherdent
Copy link

I have the same issue.... I need an ID on the second field for accessibility issues, but it only generates an ID for the hidden field.

@furkanekinci
Copy link

I have the same issue too. In my case, if I set altInput property as true, it causes generating a clone input and original input element is being hidden. Clone input is taking original inputs classes but does not take id or name attributes. Because of this problem I could not use jquery validations classic validation methods then I used class based rules etc.

@jacobmischka
Copy link
Owner

Sorry for being absent for a while. This is an upstream issue unfortunately: flatpickr/flatpickr#579 flatpickr/flatpickr#1630

@frederikhors
Copy link
Contributor Author

Sorry for being absent for a while. This is an upstream issue unfortunately: flatpickr/flatpickr#579 flatpickr/flatpickr#1630

Maybe if you write something to them thay can create a PR for that.

Or you know how to write a PR already?

@jacobmischka
Copy link
Owner

There are upstream issues already and I unfortunately don't have the time to look into a PR in the upstream library, sorry. I think you'll have to not use altInput and intead manage the inputs yourselves in svelte as a workaround in the meantime.

@jacobmischka jacobmischka added the upstream Not actually an issue with this package label Dec 15, 2023
@richmilns
Copy link

My workaround is to add a new ID (prefixed with an underscore) to the altInput DOM element and then update the corresponding label:

flatpickr('#date', {
    allowInput: true,
    altInput: true,
    altFormat: 'd/m/Y',
    dateFormat: 'Y-m-d',
    onReady(){
        if (this.altInput) {
            this.altInput.id = '_' + this.input.id;
            document.querySelector('label[for="' + this.input.id + '"]').htmlFor = '_' + this.input.id;
        }
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Not actually an issue with this package
Projects
None yet
Development

No branches or pull requests

5 participants