-
Notifications
You must be signed in to change notification settings - Fork 143
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
Reset on blur #596
Comments
Are you using the directive or any of the components? |
I'm using dp-date-picker with mode 'day' and also with mode 'time', separately. I'm using ngModel to input the initial valid value. When using the calendar or the time picker everything works but as soon the user types into the inputs then there is no way to set the initial value back on blur on close. The UI shows the just typed invalid value while the nested input keeps still the latest valid value. |
@Mariacristina88 , it sounds like you need an OnBlur event that you can apply your logic on. Am I right? |
@vlio20 Yes the onBlur event would just work, the issue is that the date-picker component is blocking any invalid value to be passed to the input itself which means that when I want to reset the UI back to the valid value, it won't see any actual change as it was already valid. Resetting the ngModel to the initial value won't work as the input has already the initial value. The UI remains wrong. At the moment I'm trying to use the dp-day-calendar and dp-time-select separatelly so that I can manipulate the input as I want but it's more work than just use the date-picker with modes. |
"My suggestion is to avoid blocking invalid values inside the component, I would rather let the invalid value in and emit an event to suggest that the value is not valid." I think that doing that will not be simple. I would suggest the following:
WDYT? |
Hi, thank you for your reply. |
Hi, I understand that the input doesn't allow invalid dates or times which don't match your configuration format so, when typing manually, you just can type anything and the date-picker will still ignoring your wrong input. The only thing that I wish to do is resetting the UI to the original valid value (on blur maybe) but at the moment this is not possible because while the UI shows a wrong not valid value, the input ngModel remains still the original valid date and for it there have not been any changes pushed.
How can we solve this UX problem? I just wish I could reset the wrong value to a valid one.
This is very easy to reproduce by the way as I've seen it in all implementation of ng2-date-picker.
Thanks!
The text was updated successfully, but these errors were encountered: