Cursor jumps to end of input field on up/down keys
andertun opened this issue · comments
I don't know if this is a bug or I'm missing something. But I can't get the arrow keys up/down to work properly. When I select the minutes (mm) and press key up it jumps to the end of the input field (after increasing the minute-value by one). The cursor doesnt jump in your demo, it stays and I can increase a value multiple times.
This is what I do:
<input type="text"
ng-model="thingy.timeModel"
datetime="mm:ss">
I made a plunker... but can't reproduce the issue. Do anyone have an idea what might be causing this (when used in a large app)?
Thanks for the plunker! Is there any other library interacting with <input>
element?
Yes probably. This is the dependancy list (removed as many as I could).
angular.module('app', [
'ui.router',
'ngStorage',
'ngDialog',
'ngAudio',
'datetime',
'plupload.directive',
'toastr'
])
Will also look into the directives we wrote ourselves, and see if any of them interact with <input>
elements.
I've increase the priority of the directive in v5.1.1. Try if it can fix your issue.
I still have the issue. I just replaced datetime.js - did you change anything in custom-input?
Nope. By increasing the priority, there is a chance to fix rendering issue (i.e. $render
function is overwritten by other directives).
BTW, does it happen to the demo of custom-input too?
https://rawgit.com/eight04/custom-input/master/demo.html
I have the exact same issue. Additionally this happens when i just fill in parts of the date with numbers eg. i'm in the (day) section and type "1" followed by "1". After the second "1" is typed the cursor jumps to the end.
Me too :(
And I tested after updating your directive with the best priority of my application.
I found the problem is when jquery is in our page: https://plnkr.co/edit/KhYvapIHBxX0nHRpwjmX?p=preview
The problem is that jQuery has different behavior with el.val(undefined)
. In jqLite, el.val()
and el.val(undefined)
both return text value, but jQuery returns an jQuery object with el.val(undefined)
. I'll fix it later.
https://github.com/eight04/angular-datetime/blob/master/lib/directive.js#L67
Also, here is the plunker with it:
https://plnkr.co/edit/TbfZhkxYs0ZReazDzYyH?p=preview
Fixed in 5.1.2.