Skip to content

Commit aafe199

Browse files
committed
fix(android): save textfield cursor on secure change
1 parent a3e15a3 commit aafe199

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/textfield/textfield.android.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
strokeDisabledColorProperty,
1313
strokeInactiveColorProperty
1414
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
15-
import { Background, Color, Utils, backgroundInternalProperty, borderBottomLeftRadiusProperty, hintProperty, placeholderColorProperty, profile } from '@nativescript/core';
15+
import { Background, Color, Font, Utils, backgroundInternalProperty, borderBottomLeftRadiusProperty, fontInternalProperty, hintProperty, placeholderColorProperty, profile } from '@nativescript/core';
16+
import { secureProperty } from '@nativescript/core/ui/text-field';
1617
import { TextFieldBase } from './textfield.common';
1718

1819
function getColorStateList(activeColor: number, inactiveColor = 1627389952, disabledColor = 1627389952) {
@@ -179,6 +180,12 @@ export class TextField extends TextFieldBase {
179180
this.layoutView.setCounterMaxLength(value);
180181
}
181182

183+
[secureProperty.setNative](value) {
184+
const cursorPos = this.editText.getSelectionStart();
185+
super[secureProperty.setNative](value);
186+
this.editText.setSelection(cursorPos);
187+
}
188+
182189
[floatingProperty.setNative](value: boolean) {
183190
this.layoutView.setHintEnabled(!!value);
184191
}

0 commit comments

Comments
 (0)