Preserve cursor position after new typehead value is set
I'm just trying to integrate typehead.js with angular.js. To achieve this I have to update typehead value each time my angular model changes, but i realized that there is a small problem with loosing cursor position after typehead('val', newValue) is used. It would be nice if setting new typehead value could preserve the actual mouse cursor position.
Quick fix for this issue:
setInputValue: function setInputValue(value, silent) { if (!silent) { var selectionStart = this.$input[0].selectionStart; var selectionEnd = this.$input[0].selectionEnd; } this.$input.val(value); if (!silent) { this.$input[0].setSelectionRange(selectionStart, selectionEnd); } silent ? this.clearHint() : this._checkInputValue(); },
To clarify, you're referring to the text cursor? Just want to make sure I understand the issue.
Yes, to the text cursor.
@marianban is this still open? I'm looking forward to working on this fantastic repository!