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

Add: readonly attribute in defaultConfig! #17

Open
ahmad-demos opened this issue Jun 3, 2022 · 2 comments
Open

Add: readonly attribute in defaultConfig! #17

ahmad-demos opened this issue Jun 3, 2022 · 2 comments

Comments

@ahmad-demos
Copy link

Hey Mathis,

when a person wants to add a new attribute readonly to the Datepicker input element as props.
This attribute does not appear, is not inserted into the input element and cannot be seen in the inspector like readonly="readonly".

Can please this readonly be added to the defaultConfig?

The reason is that on some pages we don't want to manually typing inside the Datepicker input element, because of validate.

Screenshot_2022-06-03_13-19-42

Thank you!

@mathislucka
Copy link
Owner

Hey Ahmad,

I'd propose adding something like additionalInputAttributes to the config instead and then users could do:

config = {
  additionalInputAttributes: [ { attribute: 'readonly', value: 'readonly' }, ... ]
}

dp = DatePicker(config)

At the same time, I need to check if this conflicts with some internal logic.

But, I'm not fully convinced that setting the datepicker to readonly is a good idea. It is intentional that people can actually type in the datepicker and the input is validated anyways. So you could still prevent users from inputing invalid dates.

For example, see this article for an explanation why it's a good idea to collect dates via text input: https://www.hassellinclusion.com/blog/collecting-dates-accessible/

@mathislucka
Copy link
Owner

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

2 participants