arqex / react-datetime

A lightweight but complete datetime picker react component.
2k stars 872 forks source link

onChange not triggered when renderInput is set #679

Open victorsferreira opened 4 years ago

victorsferreira commented 4 years ago

When I set the renderInput prop, the onChange event is never triggered. Even if I add the onChange in the input, it does not work. Input and styled input are rendered correctly though.

<Datetime
          onChange={(value) => console.log(value)}
          renderInput={
            (props, open, close) => (
              <input
                {...props}
                onClick={open}
                onBlur={close}
                />
            )
          }
        />

Running version is 2.16.3. Is it a bug or something is missing?

prateekmaheshwari commented 4 years ago

I have a similar problem, I have added custom MaskedInput in renderInput, but when I click in any date in calendar, it doesn't populate in the input field. Without the custom MaskedInput it works just fine. Am I missing a prop here, or its an issue?

<DateTime renderInput={(props, openCalendar) => ( <MaskedInput mask={[/[0-9]/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/]} placeholder="dd/mm/yyyy" onMouseDown={openCalendar} /> )} />

hornetDC commented 4 years ago

This is still relevant. It happens if I pass onBlur to custom input and closeOnSelect to datepicker component.

omerfdasar commented 7 months ago

Did you guys find anything ? Still relevant for me