Giter Site home page Giter Site logo

Comments (18)

pechitook avatar pechitook commented on May 19, 2024 3

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.

probablykasper avatar probablykasper commented on May 19, 2024 3

I don't want to allow all props for the reasons I already mentioned. id and aria- attributes make sense

from date-picker-svelte.

probablykasper avatar probablykasper commented on May 19, 2024 2

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.

pechitook avatar pechitook commented on May 19, 2024

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.

probablykasper avatar probablykasper commented on May 19, 2024

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.

pechitook avatar pechitook commented on May 19, 2024

@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.

probablykasper avatar probablykasper commented on May 19, 2024

We could add an id prop

from date-picker-svelte.

elton2048 avatar elton2048 commented on May 19, 2024

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.

probablykasper avatar probablykasper commented on May 19, 2024

class is supported

from date-picker-svelte.

elton2048 avatar elton2048 commented on May 19, 2024

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.

spy16 avatar spy16 commented on May 19, 2024

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.

probablykasper avatar probablykasper commented on May 19, 2024

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.

jhoddevik avatar jhoddevik commented on May 19, 2024

So ... how can we use this in forms?

from date-picker-svelte.

probablykasper avatar probablykasper commented on May 19, 2024

By binding to the date value and putting it in an input element

from date-picker-svelte.

eberhapa avatar eberhapa commented on May 19, 2024

We could add an id prop

That's exactly what I need because of Accessibility reasons to make possible.

from date-picker-svelte.

eberhapa avatar eberhapa commented on May 19, 2024

What's the problem of giving the possibility to pass all props? It would be the most flexible way.

from date-picker-svelte.

happysalada avatar happysalada commented on May 19, 2024

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.

probablykasper avatar probablykasper commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.