File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
packages/core/src/components/forms Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -129,12 +129,12 @@ export class InputGroup extends AbstractPureComponent2<IInputGroupProps & HTMLIn
129129 }
130130
131131 public componentDidMount ( ) {
132- if ( this . rightElement != null ) {
133- const { clientWidth } = this . rightElement ;
134- // small threshold to prevent infinite loops
135- if ( Math . abs ( clientWidth - this . state . rightElementWidth ) > 2 ) {
136- this . setState ( { rightElementWidth : clientWidth } ) ;
137- }
132+ this . updateInputWidth ( ) ;
133+ }
134+
135+ public componentDidUpdate ( prevProps : IInputGroupProps & HTMLInputProps ) {
136+ if ( prevProps . rightElement !== this . props . rightElement ) {
137+ this . updateInputWidth ( ) ;
138138 }
139139 }
140140
@@ -149,4 +149,16 @@ export class InputGroup extends AbstractPureComponent2<IInputGroupProps & HTMLIn
149149 </ span >
150150 ) ;
151151 }
152+
153+ private updateInputWidth ( ) {
154+ if ( this . rightElement != null ) {
155+ const { clientWidth } = this . rightElement ;
156+ // small threshold to prevent infinite loops
157+ if ( Math . abs ( clientWidth - this . state . rightElementWidth ) > 2 ) {
158+ this . setState ( { rightElementWidth : clientWidth } ) ;
159+ }
160+ } else {
161+ this . setState ( { rightElementWidth : DEFAULT_RIGHT_ELEMENT_WIDTH } ) ;
162+ }
163+ }
152164}
You can’t perform that action at this time.
0 commit comments