diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-01 04:47:05 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-01 04:47:05 +0800 |
commit | 12d34707b70e4784719593ec8d7ea57c5e601856 (patch) | |
tree | 263e872f0dc042f4dd0dfcc85c7ecc403ba83415 /packages/instant/src/components/scaling_input.tsx | |
parent | ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed (diff) | |
parent | f496096ce154e51ae0317cc91fd55d062eb6ec4f (diff) | |
download | dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar.gz dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar.bz2 dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar.lz dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar.xz dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.tar.zst dexon-sol-tools-12d34707b70e4784719593ec8d7ea57c5e601856.zip |
Merge branch 'development' into feature/instant/prod-env-switches-cdn
Diffstat (limited to 'packages/instant/src/components/scaling_input.tsx')
-rw-r--r-- | packages/instant/src/components/scaling_input.tsx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/instant/src/components/scaling_input.tsx b/packages/instant/src/components/scaling_input.tsx index e1599a316..791692257 100644 --- a/packages/instant/src/components/scaling_input.tsx +++ b/packages/instant/src/components/scaling_input.tsx @@ -28,6 +28,7 @@ export interface ScalingInputProps { maxLength?: number; scalingSettings: ScalingSettings; isDisabled: boolean; + hasAutofocus: boolean; } export interface ScalingInputState { @@ -51,6 +52,7 @@ export class ScalingInput extends React.Component<ScalingInputProps, ScalingInpu maxLength: 7, scalingSettings: defaultScalingSettings, isDisabled: false, + hasAutofocus: false, }; public state: ScalingInputState = { inputWidthPxAtPhaseChange: undefined, @@ -96,6 +98,12 @@ export class ScalingInput extends React.Component<ScalingInputProps, ScalingInpu inputWidthPx: this._getInputWidthInPx(), }; } + public componentDidMount(): void { + // Trigger an initial notification of the calculated fontSize. + const currentPhase = ScalingInput.getPhaseFromProps(this.props); + const currentFontSize = ScalingInput.calculateFontSizeFromProps(this.props, currentPhase); + this.props.onFontSizeChange(currentFontSize); + } public componentDidUpdate( prevProps: ScalingInputProps, prevState: ScalingInputState, @@ -123,7 +131,7 @@ export class ScalingInput extends React.Component<ScalingInputProps, ScalingInpu } } public render(): React.ReactNode { - const { isDisabled, fontColor, onChange, placeholder, value, maxLength } = this.props; + const { hasAutofocus, isDisabled, fontColor, onChange, placeholder, value, maxLength } = this.props; const phase = ScalingInput.getPhaseFromProps(this.props); return ( <Input @@ -136,6 +144,7 @@ export class ScalingInput extends React.Component<ScalingInputProps, ScalingInpu width={this._calculateWidth(phase)} maxLength={maxLength} disabled={isDisabled} + autoFocus={hasAutofocus} /> ); } |