File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import {
32
32
placeholderColorProperty
33
33
} from '@nativescript/core' ;
34
34
import { textProperty } from '@nativescript/core/ui/text-base' ;
35
+ import { layout } from '@nativescript/core/utils' ;
35
36
import { TextFieldBase } from './textfield.common' ;
36
37
37
38
@NativeClass
@@ -171,13 +172,19 @@ export class TextField extends TextFieldBase {
171
172
}
172
173
173
174
this . firstEdit = false ;
174
- if ( this . width === 'auto' ) {
175
+ if ( this . mCanAutoSize ) {
175
176
// if the textfield is in auto size we need to request a layout to take the new text width into account
176
177
this . requestLayout ( ) ;
177
178
}
178
179
return true ;
179
180
// return super.textFieldShouldChangeCharactersInRangeReplacementString(textField, range, replacementString);
180
181
}
182
+ private mCanAutoSize = false ;
183
+ public onMeasure ( widthMeasureSpec : number , heightMeasureSpec : number ) : void {
184
+ const widthMode = layout . getMeasureSpecMode ( widthMeasureSpec ) ;
185
+ this . mCanAutoSize = widthMode !== layout . EXACTLY ;
186
+ super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ;
187
+ }
181
188
182
189
_getTextInsetsForBounds ( insets : UIEdgeInsets ) : UIEdgeInsets {
183
190
const style = this . style ;
You can’t perform that action at this time.
0 commit comments