react-toolkit icon indicating copy to clipboard operation
react-toolkit copied to clipboard

Cannot override onReset method of DateInput component

Open lilian-delouvy opened this issue 2 years ago • 5 comments

Cannot override onReset method of DateInput component

msedge_vKHHwpSYkf

Toolkit version : 2.0.0

Expected

The onReset method of DateInput should be either available to override, or should return the current day value and not display "jj/mm/aaaa".

Actual

It is impossible to override this method, and when you click on the reset button, no value is returned to the parent component, hence it is impossible to know when the user clicked on this button.

lilian-delouvy avatar Dec 21 '22 08:12 lilian-delouvy

Hello,

I see that the pull request https://github.com/AxaFrance/react-toolkit/pull/1032 provides a solution by making the component call the onChange method and return null when the reset button is clicked on.

I wonder if it would not be better to declare an onReset function prop that the developer could override. Currently, clicking on the reset button makes the viewValue become "jj/mm/aaaa" which is not always the result the developer wants.

To provide some context, I use this component in a bigger form that has a "reset" button to reinit all form components. Due to the current behaviour of this component, our reset button does not work anymore, and clicking on the reset button of the component makes "jj/mm/aaaa" appear, but we would like to display the current date instead.

Maybe it would be better to allow the developer to provide an onReset prop and to control the viewValue directly ?

lilian-delouvy avatar Jun 02 '23 15:06 lilian-delouvy

We implemented this way in order to be compliant with the previous version. But your solution was one of the solutions we had in mind.

What do you think @arnaudforaison @johnmeunier ?

EmmanuelDemey avatar Jun 08 '23 08:06 EmmanuelDemey

@arnaudforaison @johnmeunier que pensez-vous du message de @lilian-delouvy ?

EmmanuelDemey avatar Jun 29 '23 11:06 EmmanuelDemey

We need to discuss this further to see which solution we would implement.

MartinWeb avatar Sep 12 '23 12:09 MartinWeb

I managed to do it by settings the onInput event : onInput={e => { if (!e.target.value) { // you can implement your logic here } }}

Kubik-a avatar Dec 01 '23 13:12 Kubik-a