Skip to main content
Ionic

Ionic V1 Cursor Lost

By October 12, 2019February 13th, 2020No Comments

Sometimes span inside label takes focus along with input. Sometimes first the input takes focus then it moves to span. This transition removes the focus from the input but the keyboard still stays open. What you type in won’t register.

Solution 1: Removing span resolves the issue.

Solution 2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if (document.activeElement.nodeName === 'SPAN') {
   
    if (jQuery(document.activeElement).hasClass('input-label')) {
        jQuery(document.activeElement).siblings().find('input').focus();
        jQuery(document.activeElement).val(jQuery(document.activeElement).val());
    }
   
}

// .focus is hocus-pocus. this is what does the trick (focus)
if (document.activeElement.nodeName === 'INPUT') {
    jQuery(document.activeElement).val(jQuery(document.activeElement).val());
}

// Solves it for the feedback page.
if (document.activeElement.nodeName === 'TEXTAREA') {
    if (!jQuery(document.activeElement).val()) {
       
        jQuery(document.activeElement).val(" ");
        setTimeout(function () {
            jQuery(document.activeElement).val("");
        }, 1)
    } else {
        jQuery(document.activeElement).val(jQuery(document.activeElement).val());
    }
}