Hacker0x01 / react-datepicker

A simple and reusable datepicker component for React
https://reactdatepicker.com/
MIT License
7.95k stars 2.24k forks source link

onChange(Raw) gets onClick event? #3949

Closed sKopheK closed 5 months ago

sKopheK commented 1 year ago

Describe the bug instead of expected change event at input field passed to onChangeRaw callback, I'm receiving some weird onClick syntetic thingy

To Reproduce

<ReactDatePicker
    onChangeRaw={props.onChange}
    onChange={() => { }}
/>

Expected behavior get original event what as you'd subscribe to change of input field itself

Screenshots imagen

Desktop (please complete the following information):

sKopheK commented 1 year ago

also, not part of this repo, but @types/react-datepicker - still worth notificing: onChangeRaw?(event: React.FocusEvent<HTMLInputElement>): void;

sKopheK commented 1 year ago

actually same weird event is given on onChange={(date, event) => ...}

yuki0410-dev commented 5 months ago

@sKopheK onChangeRaw is called in two places in index.jsx.

https://github.com/Hacker0x01/react-datepicker/blob/5261cbd15d8eff849cf76d4865126ce2b4ccb973/src/index.jsx#L542 https://github.com/Hacker0x01/react-datepicker/blob/5261cbd15d8eff849cf76d4865126ce2b4ccb973/src/index.jsx#L586

From the capture, it is assumed that it is called via handleSelect. (Judging from target and type).

There didn't seem to be anything odd about it as a reactEvent. If you need nativeEvent, go to e.nativeEvent. https://stackoverflow.com/a/70426848

yuki0410-dev commented 5 months ago

( cc: @martijnrusschen )