Closed henkesn closed 2 years ago
Throughout my experience, submitting a form by hitting enter on an input field has always been a thing needs to be prevented. So I was unable to imagine this could be an issue. Could you please give me some more examples? I'd like to look deeper into this.
Thanks for your reply! I think, preventing enter form submission really depends on the actual use case and is not in the datepicker's responsability. If you need to prevent it on a complex form, you need a concept for non date fields anyway. Some examples, where enter can be very comfortable:
I was actually expecting to see other examples than implicit submission, but it's not important now. I admit I was lazy simplifying the event cancellation without thinking well why bootstrap-datepicker does it in some cases but not in other cases. There shouldn't be restrictions without reason.
I'll review the cases and remove unnecessary cancellations. Thanks for the suggestion.
First of all: Thank you for sharing this great project!
Currently, the datepicker objects listens on the keydown event including preventDefault: https://github.com/mymth/vanillajs-datepicker/blob/9de5051545626b116db3d213b0b1e429f296967c/js/events/inputFieldListeners.js#L86.
In a form with a bunch of inputs, it feels a bit inconsistent/clumsy, that some fields (non-datepicker fields) submit on enter and datepicker fields dont, especially when the datepicker input has not been changed.