Comments (18)
It seems we have some alignment that at least id
and aria-
attributes are needed to have some basic accessibility support.
I think the remaining big item is about the implementation strategy. The way I see it we have at least two potential solutions
1- Expose specific, hardcoded attributes for id
, and all the aria-
attributes
2- Use something like I suggested initially <input {...$$restProps}>
which would allow us to future-proof this library and even support valid custom attributes like data-
ones. I could put up a PR just to discuss the approach here by looking at an example
Any pros/cons you all see here? cc @probablykasper
from date-picker-svelte.
I don't want to allow all props for the reasons I already mentioned. id
and aria-
attributes make sense
from date-picker-svelte.
Ah yeah you're right, it styles the <div>
container instead of the <input>
. Maybe it would work fine to change it to apply to <input>
from date-picker-svelte.
After some proper look at the Svelte documentation, I found https://svelte.dev/docs#template-syntax-attributes-and-props
$$restProps
contains only the props which are not declared with export. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as $$props, and is likewise not recommended.
<input {...$$restProps}>
I think this could work.
from date-picker-svelte.
I'm not too sure about this, what's your use case? I wouldn't want people to for example add a name
because that would be a weird format to use and it would only work with the input
from date-picker-svelte.
@probablykasper the most straightforward use case I can think of is adding an id to be able to semantically use a label
<label for="some input>
<input id="some input" />
</label>
from date-picker-svelte.
We could add an id prop
from date-picker-svelte.
It is better to allow extra class attributes to be in <input>
element too for layout customization using like tailwind css.
from date-picker-svelte.
class
is supported
from date-picker-svelte.
class
is supported
I am not sure if this is the case, but the source doesn't show the class for the <input>
element getting the class attributes (I am the <input>
element inside the <div>
wrapper element).
<input
class:invalid={!valid}
type="text"
value={text}
from date-picker-svelte.
example add a name because that would be a weird format to use
Could you elaborate on this please? To make it work with forms, this is needed.
Some reasons to allow control on attributes of input:
- To make it work with forms (e.g., for use with SvelteKit actions), having the ability to set
name
is useful. - To add labels
id
would be needed. - To be able to set all the
aria-
attributes
Overall, I think allowing all standard input attributes, except where it would interfere with the custom logic of the component would be good idea i think. This way, it would be an enhanced version of input type="date"
and allow all the patterns that we can use with it (#UseThePlatform
🙂)
from date-picker-svelte.
Could you elaborate on this please? To make it work with forms, this is needed.
The input is a customizable user-facing value, not a data value. Parsing on the server would get complicated, especially for user-dependent formats. It also wouldn't work for the DatePicker
component.
I'd be happy to have other attributes that make sense, like id
.
Would be good to have built-in aria-
attributes
from date-picker-svelte.
So ... how can we use this in forms?
from date-picker-svelte.
By binding to the date value and putting it in an input element
from date-picker-svelte.
We could add an id prop
That's exactly what I need because of Accessibility reasons to make possible.
from date-picker-svelte.
What's the problem of giving the possibility to pass all props? It would be the most flexible way.
from date-picker-svelte.
Could we also add a "required" attribute to be passed.
if used in a form and the user didn't input, but is trying to submit, most browser have auto focuse on the required field. This would be nice to have.
from date-picker-svelte.
required
and id
are now supported. For name
, see
About aria-
, feel free to open a new issue with more concrete details
from date-picker-svelte.
Related Issues (20)
- svelte 4 update ? HOT 2
- Setting text class in DateInput? HOT 1
- Is there any way to change year to be buddhist era? HOT 1
- Feature Request: Slot Support for Day Customization HOT 3
- Allow date-fns formatting HOT 1
- REPL broken, loading date-fns HOT 2
- Input field showing date only, no date-time? HOT 3
- Add name and class property to DateInput HOT 13
- Add ID to input field
- Enhancement Request: Implement 'readonly' Attribute in Input feild HOT 2
- picker title format request... HOT 4
- Month/year view not updating when value changes externally, with `browseWithoutSelecting`
- [Bug] TimePrecision does not work correctly when set `min` value HOT 6
- Year is maxing out at 2024 HOT 2
- Value does not react when updating time, only when updating date HOT 10
- Fire `select` when date picker is defocused
- Add `input` event
- timePrecision does not set output precision HOT 1
- different color variable for background and popover HOT 1
- Set autocomplete to off HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from date-picker-svelte.