FIX: Compact tag picker input not focused in iOS (#22922)
Should fix an iOS regression in f5e8e73
. iOS does not pull up the keyboard if the `.focus()` call is delayed by a rendering timeout or an asynchronous ajax call. This PR adds earlier `.focus()` calls if the input element is present.
This commit is contained in:
parent
09502cf627
commit
5dc3a276c8
|
@ -1004,6 +1004,10 @@ export default Component.extend(
|
||||||
this.selectKit.options.filterable || this.selectKit.options.allowAny,
|
this.selectKit.options.filterable || this.selectKit.options.allowAny,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.selectKit.options.useHeaderFilter) {
|
||||||
|
this._focusFilterInput();
|
||||||
|
}
|
||||||
|
|
||||||
this.triggerSearch();
|
this.triggerSearch();
|
||||||
|
|
||||||
this._safeAfterRender(() => {
|
this._safeAfterRender(() => {
|
||||||
|
@ -1044,14 +1048,16 @@ export default Component.extend(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setting focus as early as possible is best for iOS
|
||||||
|
// because render/promise delays may cause keyboard not to show
|
||||||
|
if (!forceHeader) {
|
||||||
|
this._focusFilterInput();
|
||||||
|
}
|
||||||
|
|
||||||
this._safeAfterRender(() => {
|
this._safeAfterRender(() => {
|
||||||
const input = this.getFilterInput();
|
const input = this.getFilterInput();
|
||||||
if (!forceHeader && input) {
|
if (!forceHeader && input) {
|
||||||
input.focus({ preventScroll: true });
|
this._focusFilterInput();
|
||||||
|
|
||||||
if (typeof input.selectionStart === "number") {
|
|
||||||
input.selectionStart = input.selectionEnd = input.value.length;
|
|
||||||
}
|
|
||||||
} else if (!this.selectKit.options.preventHeaderFocus) {
|
} else if (!this.selectKit.options.preventHeaderFocus) {
|
||||||
const headerContainer = this.getHeader();
|
const headerContainer = this.getHeader();
|
||||||
headerContainer && headerContainer.focus({ preventScroll: true });
|
headerContainer && headerContainer.focus({ preventScroll: true });
|
||||||
|
@ -1059,6 +1065,18 @@ export default Component.extend(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_focusFilterInput() {
|
||||||
|
const input = this.getFilterInput();
|
||||||
|
|
||||||
|
if (input && document.activeElement !== input) {
|
||||||
|
input.focus({ preventScroll: true });
|
||||||
|
|
||||||
|
if (typeof input.selectionStart === "number") {
|
||||||
|
input.selectionStart = input.selectionEnd = input.value.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getFilterInput() {
|
getFilterInput() {
|
||||||
return document.querySelector(`#${this.selectKit.uniqueID}-filter input`);
|
return document.querySelector(`#${this.selectKit.uniqueID}-filter input`);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue