Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override onReset method of DateInput component #1002

Closed
lilian-delouvy opened this issue Dec 21, 2022 · 5 comments · Fixed by #1173
Closed

Cannot override onReset method of DateInput component #1002

lilian-delouvy opened this issue Dec 21, 2022 · 5 comments · Fixed by #1173
Labels
help wanted Extra attention is needed

Comments

@lilian-delouvy
Copy link

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
Copy link
Author

Hello,

I see that the pull request #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 ?

@EmmanuelDemey
Copy link

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
Copy link

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

@MartinWeb
Copy link
Contributor

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

@MartinWeb MartinWeb added the help wanted Extra attention is needed label Sep 12, 2023
@Kubik-a
Copy link

Kubik-a commented Dec 1, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
4 participants