Git Product home page Git Product logo

Comments (5)

devken-net avatar devken-net commented on June 2, 2024

I agree, date picker should close onBlur or onFocusOut of the component.

from react-datetime.

arqex avatar arqex commented on June 2, 2024

It's not possible to close it on blur because when the user clicks on the calendar, the input loses the focus and it would get closed.

You could try it yourselves with something like:

<DateTime ref="picker" inputProps={{ onBlur: () => this.refs.picker.closeCalendar() }} />

from react-datetime.

switchtrue avatar switchtrue commented on June 2, 2024

This actually covers my use case well. Im mainly concerned when there are multiple DateTime widgets on the screen in a single form and you quickly tab through the form and they all remain open.

I just implemented the above and it works well - however, the next/previous buttons are marked us as button elements so when tabbing the focus goes to these rather than the next field. Is there any particular reason these are buttons given that the rest of the widget doesn't seem to be keyboard accessible? These could be changed to spans.

from react-datetime.

cleanunicorn avatar cleanunicorn commented on June 2, 2024

For me the example did not work, I could not select any date anymore. This hack works for me

inputProps={{
    onBlur: () => {
        setTimeout(
            () => this.refs.picker.closeCalendar(),
            100
        )
    }
}}

from react-datetime.

simeg avatar simeg commented on June 2, 2024

@mleonard87 I think the <button> elements are replaced with <span> elements. I've tried having multiple components on a single page and I can successfully tab between them without anything else but the <input> element getting focus.

Thanks for the solution and comments. I will close this now, if anyone is still having issues just re-open this again.

from react-datetime.

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.