GithubHelp home page GithubHelp logo

Comments (8)

abaksha-sc avatar abaksha-sc commented on June 6, 2024 3

But firstInputRef sounds really handy!

It's better and easier just to provide prop like firstInputId to make possible to associate the label with the first input.

<label for="date-picker">Date:</label>
<DatePicker firstInputId="date-picker" />

It will be similar to prop inputId of popular "react-select".

But I was also looking for some ref prop to add tabIndex="-1" to the button with calendar icon to prevent focus when user navigates on form with keyboard. So some global ref will be useful for me to execute ref.querySelector(button)

from react-date-picker.

frederickf avatar frederickf commented on June 6, 2024 1

I'm a little confused. What does "ref is a bad idea for a name here" mean? What name? And if think using ref is a bad idea, then what would firstInputRef be? I'm fine with whatever you prefer, I'm just trying to understand what you're proposing.

UPDATE
I reread your comment and I think I understand now. You're saying to use a new property named firstInputRef that takes a ref that is assigned to the first input. EX

const inputRef = useRef()

<DatePicker firstInputRef={inputRef} />

Is that right?

from react-date-picker.

wojtekmaj avatar wojtekmaj commented on June 6, 2024

Ref was never documented and (even sudden) lack of it can't be considered a bug. What is your use case? Focusing input?

from react-date-picker.

frederickf avatar frederickf commented on June 6, 2024

Thanks for the quick response. We create a label for the date picker, and when a user clicks on the label we were using ref to focus on the first input.

I also have a new use I was intending to use it for, which is exposing some details about an invalid change. For example, getting the field that is invalid and it's current invalid value so I can provide a more detailed error message to the user.

I'd be happy to do a PR for those if you think they are valid use cases. Either by adding support for ref, or something different.

from react-date-picker.

wojtekmaj avatar wojtekmaj commented on June 6, 2024

ref is a bad idea for a name here; it should either be a reference to component itself, or to a root (and usually the only, because it's for a simple cases like Button component) element rendered by this component.

But firstInputRef sounds really handy!

from react-date-picker.

wojtekmaj avatar wojtekmaj commented on June 6, 2024

Yep that's right! Sorry if I failed to explain it clearly.

from react-date-picker.

frederickf avatar frederickf commented on June 6, 2024

I've opened a PR based on our discussion #625

from react-date-picker.

github-actions avatar github-actions commented on June 6, 2024

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

from react-date-picker.

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.