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 {
3232 placeholderColorProperty
3333} from '@nativescript/core' ;
3434import { textProperty } from '@nativescript/core/ui/text-base' ;
35+ import { layout } from '@nativescript/core/utils' ;
3536import { TextFieldBase } from './textfield.common' ;
3637
3738@NativeClass
@@ -171,13 +172,19 @@ export class TextField extends TextFieldBase {
171172 }
172173
173174 this . firstEdit = false ;
174- if ( this . width === 'auto' ) {
175+ if ( this . mCanAutoSize ) {
175176 // if the textfield is in auto size we need to request a layout to take the new text width into account
176177 this . requestLayout ( ) ;
177178 }
178179 return true ;
179180 // return super.textFieldShouldChangeCharactersInRangeReplacementString(textField, range, replacementString);
180181 }
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+ }
181188
182189 _getTextInsetsForBounds ( insets : UIEdgeInsets ) : UIEdgeInsets {
183190 const style = this . style ;
You can’t perform that action at this time.
0 commit comments