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

caret position tracking while editing input #211

Closed
wants to merge 2 commits into from
Closed

caret position tracking while editing input #211

wants to merge 2 commits into from

Conversation

viict
Copy link

@viict viict commented Jul 22, 2016

Might have a better way to do this, but, I needed it in a hurry and it solves the problem for me as far as our QA have gonne so far.

@coveralls
Copy link

coveralls commented Jul 22, 2016

Coverage Status

Coverage remained the same at 97.297% when pulling 6338d42 on viict:caret-position-tracking into 65c7f2b on assisrafael:master.

@assisrafael
Copy link
Owner

Thank you for the pull request.
Track caret position is a very interesting feature! However you need to implement e2e tests for this pull request to be merged.
Are you familiar with protractor?

@viict
Copy link
Author

viict commented Jul 25, 2016

@assisrafael no, but, I will look into it and see if I can manage this test out

@assisrafael
Copy link
Owner

Thank you.

@juancarrey
Copy link

Hi, could this actually be used to provide a way of having default caret just before the decimal places ?
It is very annoying for users to always have to enter decimal places, and type 500 to put $5,00

@viict
Copy link
Author

viict commented Aug 8, 2016

@juancarrey I'm currently trying to fix a minor problem and I will look into that right after I do the test case that I'm in dept with this project 🐌

@jayrmotta
Copy link

jayrmotta commented Dec 21, 2016

@viict I've tested your fork but for some reason I'm getting this exception:

TypeError: Cannot read property 'selectionStart' of undefined
    at Object.caretGet [as get] (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:93870:17)
    at Array.parser (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:93899:40)
    at NgModelController.$$parseAndValidate (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:38346:39)
    at NgModelController.$commitViewValue (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:38336:11)
    at http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:38479:15
    at Scope.$eval (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:28006:29)
    at Scope.$apply (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:28106:26)
    at NgModelController.$$debounceViewValueCommit (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:38478:15)
    at NgModelController.$setViewValue (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:38450:13)
    at HTMLInputElement.listener (http://10.0.1.236:3000/vendor.bundle.js?ec0f38d8a48f744511d3:34473:13) undefined

I've tracked the exception to this line where you're trying to access element[0] but apparently it's not a collection.

I'm running it on Android 6.0.1 > Chrome Mobile 55.0.2883.91 using the directive ui-br-cpf-mask.

Any ideas?

@ianldgs
Copy link

ianldgs commented Feb 13, 2017

One possible solution is this: bendrucker/angular-credit-cards@b6c5644

@jadir-junior
Copy link

for me that is not work

@vilasboas
Copy link

still not working for me

set : function caretSet(element, pos) {
if (element[0].setSelectionRange) {
element[0].focus();
element[0].setSelectionRange(pos,pos);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi guys!

I had this problem too, but i modify a little this PR... placing the (setTimeout function) encapsulating ==> element[0].setSelectionRange(pos,pos);

like this:
setTimeout(function () {
element[0].setSelectionRange(pos,pos);
}, 0);

this work for me... regards

@leuterio
Copy link

leuterio commented May 30, 2017

This worked for me:
Inside the input tag add:
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"

@assisrafael
Copy link
Owner

Closing due to inactivity.
Please reopen this PR if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants