mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Merge pull request #2995 from NativeScript/keyboard
Fix: ListView with TextField in the Item template not showing Keyboar…
This commit is contained in:
11
apps/app/ui-tests-app/issues/issue-2942.ts
Normal file
11
apps/app/ui-tests-app/issues/issue-2942.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export function onButtonLoaded(args){
|
||||||
|
if (args.object.android){
|
||||||
|
args.object.android.setFocusableInTouchMode(true);
|
||||||
|
args.object.android.setFocusable(true);
|
||||||
|
args.object.android.setClickable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function onListViewLoaded(args){
|
||||||
|
args.object.items = [1];
|
||||||
|
}
|
13
apps/app/ui-tests-app/issues/issue-2942.xml
Normal file
13
apps/app/ui-tests-app/issues/issue-2942.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
|
||||||
|
<StackLayout>
|
||||||
|
<Button height="100" width="100" loaded="onButtonLoaded" text="Click me 3rd (Android)" style.fontSize="8"/>
|
||||||
|
<ListView loaded="onListViewLoaded">
|
||||||
|
<ListView.itemTemplate>
|
||||||
|
<StackLayout>
|
||||||
|
<TextField text="Click me 1st"/>
|
||||||
|
<TextField text="Click me 2nd" keyboardType="number"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ListView.itemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</Page>
|
@ -13,6 +13,7 @@ export function pageLoaded(args: EventData) {
|
|||||||
|
|
||||||
examples.set("2911", "issues/issue-2911");
|
examples.set("2911", "issues/issue-2911");
|
||||||
examples.set("2674", "issues/issue-2674");
|
examples.set("2674", "issues/issue-2674");
|
||||||
|
examples.set("2942", "issues/issue-2942");
|
||||||
|
|
||||||
let viewModel = new SubMianPageViewModel(wrapLayout, examples);
|
let viewModel = new SubMianPageViewModel(wrapLayout, examples);
|
||||||
page.bindingContext = viewModel;
|
page.bindingContext = viewModel;
|
||||||
|
@ -93,6 +93,9 @@ export function buildUIWithWeakRefAndInteract<T extends view.View>(createFunc: (
|
|||||||
}
|
}
|
||||||
|
|
||||||
sp.removeChild(weakRef.get());
|
sp.removeChild(weakRef.get());
|
||||||
|
|
||||||
|
TKUnit.wait(1); // Wait for the TextField/TextView to close its keyboard so it can be released.
|
||||||
|
|
||||||
if (newPage.ios) {
|
if (newPage.ios) {
|
||||||
/* tslint:disable:no-unused-expression */
|
/* tslint:disable:no-unused-expression */
|
||||||
// Could cause GC on the next call.
|
// Could cause GC on the next call.
|
||||||
|
@ -4,6 +4,9 @@ import enums = require("ui/enums");
|
|||||||
import utils = require("utils/utils");
|
import utils = require("utils/utils");
|
||||||
import types = require("utils/types");
|
import types = require("utils/types");
|
||||||
|
|
||||||
|
//https://github.com/NativeScript/NativeScript/issues/2942
|
||||||
|
let dismissKeyboardTimeoutId: number;
|
||||||
|
|
||||||
export class EditableTextBase extends common.EditableTextBase {
|
export class EditableTextBase extends common.EditableTextBase {
|
||||||
private _android: android.widget.EditText;
|
private _android: android.widget.EditText;
|
||||||
private _textWatcher: android.text.TextWatcher;
|
private _textWatcher: android.text.TextWatcher;
|
||||||
@ -69,13 +72,26 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFocus) {
|
if (hasFocus) {
|
||||||
|
if (dismissKeyboardTimeoutId){
|
||||||
|
// https://github.com/NativeScript/NativeScript/issues/2942
|
||||||
|
// Don't hide the keyboard since another (or the same) EditText has gained focus.
|
||||||
|
clearTimeout(dismissKeyboardTimeoutId);
|
||||||
|
dismissKeyboardTimeoutId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (owner._dirtyTextAccumulator) {
|
if (owner._dirtyTextAccumulator) {
|
||||||
owner._onPropertyChangedFromNative(EditableTextBase.textProperty, owner._dirtyTextAccumulator);
|
owner._onPropertyChangedFromNative(EditableTextBase.textProperty, owner._dirtyTextAccumulator);
|
||||||
owner._dirtyTextAccumulator = undefined;
|
owner._dirtyTextAccumulator = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.dismissSoftInput();
|
dismissKeyboardTimeoutId = setTimeout(() => {
|
||||||
|
// https://github.com/NativeScript/NativeScript/issues/2942
|
||||||
|
// Dismiss the keyboard if focus goes to something different from EditText.
|
||||||
|
owner.dismissSoftInput();
|
||||||
|
dismissKeyboardTimeoutId = null;
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,6 +47,7 @@ export class ListView extends common.ListView {
|
|||||||
|
|
||||||
public _createUI() {
|
public _createUI() {
|
||||||
this._android = new android.widget.ListView(this._context);
|
this._android = new android.widget.ListView(this._context);
|
||||||
|
this._android.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||||
|
|
||||||
// Fixes issue with black random black items when scrolling
|
// Fixes issue with black random black items when scrolling
|
||||||
this._android.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
this._android.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
||||||
@ -178,7 +179,7 @@ function ensureListViewAdapterClass() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getCount() {
|
public getCount() {
|
||||||
return this._listView && this._listView.items ? this._listView.items.length : 0;
|
return this._listView && this._listView.items && this._listView.items.length ? this._listView.items.length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getItem(i: number) {
|
public getItem(i: number) {
|
||||||
|
Reference in New Issue
Block a user