Skip to content

Commit 0254f09

Browse files
committed
Fix for the focus problem (bug KazanExpress#453)
1 parent 122e5ef commit 0254f09

File tree

6 files changed

+42
-28
lines changed

6 files changed

+42
-28
lines changed

dist/cjs.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function _await(value, then, direct) {
7575
}return result;
7676
}function _finally(body, finalizer) {
7777
try {
78-
7978
var result = body();
8079
} catch (e) {
8180
return finalizer();
@@ -527,17 +526,23 @@ function _await(value, then, direct) {
527526
}
528527
},
529528
suggestionClick: function suggestionClick(suggestion, e) {
529+
var _this8 = this;
530+
530531
this.$emit('suggestion-click', suggestion, e);
531532
this.select(suggestion);
532533

533534
if (!this.preventHide) this.hideList();
534535

535-
/// Ensure, that all needed flags are off before finishing the click.
536-
this.isClicking = false;
536+
if (this.isClicking) {
537+
setTimeout(function () {
538+
_this8.inputElement.focus();
539+
540+
/// Ensure, that all needed flags are off before finishing the click.
541+
_this8.isClicking = false;
542+
}, 0);
543+
}
537544
},
538545
onBlur: function onBlur(e) {
539-
var _this8 = this;
540-
541546
if (this.isInFocus) {
542547

543548
/// Clicking starts here, because input's blur occurs before the suggestionClick
@@ -551,9 +556,6 @@ function _await(value, then, direct) {
551556
this.$emit('blur', e);
552557
} else if (e && e.isTrusted && !this.isTabbed) {
553558
this.isFalseFocus = true;
554-
setTimeout(function () {
555-
_this8.inputElement.focus();
556-
}, 200);
557559
}
558560
} else {
559561
this.inputElement.blur();
@@ -573,7 +575,9 @@ function _await(value, then, direct) {
573575
// Show list only if the item has not been clicked (isFalseFocus indicates that click was made earlier)
574576
if (!this.isClicking && !this.isFalseFocus) {
575577
this.showSuggestions();
576-
}this.isFalseFocus = false;
578+
}
579+
580+
this.isFalseFocus = false;
577581
},
578582
onInput: function onInput(inputEvent) {
579583
var value = !inputEvent.target ? inputEvent : inputEvent.target.value;

dist/es6.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function _await(value, then, direct) {
6969
}return result;
7070
}function _finally(body, finalizer) {
7171
try {
72-
7372
var result = body();
7473
} catch (e) {
7574
return finalizer();
@@ -498,8 +497,14 @@ function _await(value, then, direct) {
498497

499498
if (!this.preventHide) this.hideList();
500499

501-
/// Ensure, that all needed flags are off before finishing the click.
502-
this.isClicking = false;
500+
if (this.isClicking) {
501+
setTimeout(() => {
502+
this.inputElement.focus();
503+
504+
/// Ensure, that all needed flags are off before finishing the click.
505+
this.isClicking = false;
506+
}, 0);
507+
}
503508
},
504509
onBlur(e) {
505510
if (this.isInFocus) {
@@ -515,9 +520,6 @@ function _await(value, then, direct) {
515520
this.$emit('blur', e);
516521
} else if (e && e.isTrusted && !this.isTabbed) {
517522
this.isFalseFocus = true;
518-
setTimeout(() => {
519-
this.inputElement.focus();
520-
}, 200);
521523
}
522524
} else {
523525
this.inputElement.blur();
@@ -542,7 +544,9 @@ function _await(value, then, direct) {
542544
// Show list only if the item has not been clicked (isFalseFocus indicates that click was made earlier)
543545
if (!this.isClicking && !this.isFalseFocus) {
544546
this.showSuggestions();
545-
}this.isFalseFocus = false;
547+
}
548+
549+
this.isFalseFocus = false;
546550
},
547551
onInput(inputEvent) {
548552
const value = !inputEvent.target ? inputEvent : inputEvent.target.value;

dist/es7.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,14 @@ var VueSimpleSuggest = {
443443

444444
if (!this.preventHide) this.hideList();
445445

446-
/// Ensure, that all needed flags are off before finishing the click.
447-
this.isClicking = false;
446+
if (this.isClicking) {
447+
setTimeout(() => {
448+
this.inputElement.focus();
449+
450+
/// Ensure, that all needed flags are off before finishing the click.
451+
this.isClicking = false;
452+
}, 0);
453+
}
448454
},
449455
onBlur(e) {
450456
if (this.isInFocus) {
@@ -460,9 +466,6 @@ var VueSimpleSuggest = {
460466
this.$emit('blur', e);
461467
} else if (e && e.isTrusted && !this.isTabbed) {
462468
this.isFalseFocus = true;
463-
setTimeout(() => {
464-
this.inputElement.focus();
465-
}, 200);
466469
}
467470
} else {
468471
this.inputElement.blur();

dist/iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/vue-simple-suggest.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,14 @@ export default {
467467
468468
if (!this.preventHide) this.hideList()
469469
470-
/// Ensure, that all needed flags are off before finishing the click.
471-
this.isClicking = false
470+
if (this.isClicking) {
471+
setTimeout(() => {
472+
this.inputElement.focus()
473+
474+
/// Ensure, that all needed flags are off before finishing the click.
475+
this.isClicking = false
476+
}, 0)
477+
}
472478
},
473479
onBlur (e) {
474480
if (this.isInFocus) {
@@ -484,9 +490,6 @@ export default {
484490
this.$emit('blur', e)
485491
} else if (e && e.isTrusted && !this.isTabbed) {
486492
this.isFalseFocus = true
487-
setTimeout(() => {
488-
this.inputElement.focus()
489-
}, 200)
490493
}
491494
} else {
492495
this.inputElement.blur()

0 commit comments

Comments
 (0)