Skip to content

Commit

Permalink
🎨 Jump to end of input
Browse files Browse the repository at this point in the history
When using the virtual keyboard, once opening, the cursor will jump to the end of the input field.
  • Loading branch information
BillyBlaze committed Dec 12, 2017
1 parent 328e994 commit 8436158
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions octoprint_touchui/static/js/touchui.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,13 @@ TouchUI.prototype.components.keyboard = {
},

onShow: function(event, keyboard, el) {
// Set
var prev = keyboard.$preview.get(0);
prev.selectionStart = prev.selectionEnd = prev.value.length;
// Set the input cursor to the end of the input field
setTimeout(function() {
var prev = keyboard.$preview.get(0);
if (prev) {
prev.selectionStart = prev.selectionEnd = prev.value.length;
}
}, 10);

keyboard.$keyboard.find("button").on("mousedown", function(e) {
$(e.target).addClass("touch-focus");
Expand Down
10 changes: 7 additions & 3 deletions source/js/components/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ TouchUI.prototype.components.keyboard = {
},

onShow: function(event, keyboard, el) {
// Set
var prev = keyboard.$preview.get(0);
prev.selectionStart = prev.selectionEnd = prev.value.length;
// Set the input cursor to the end of the input field
setTimeout(function() {
var prev = keyboard.$preview.get(0);
if (prev) {
prev.selectionStart = prev.selectionEnd = prev.value.length;
}
}, 10);

keyboard.$keyboard.find("button").on("mousedown", function(e) {
$(e.target).addClass("touch-focus");
Expand Down

0 comments on commit 8436158

Please sign in to comment.