Skip to content

Commit e2cb596

Browse files
authored
Giving Input Slider text box enough width (microsoft#364)
1 parent 1b8a7dd commit e2cb596

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/view/components/toolbar/InputSlider.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class InputSlider extends React.Component<ISliderProps, any, any> {
3838
.length
3939
}}[.]{0,${nbDecimals > 0 ? 1 : 0}}[0-9]{0,${nbDecimals}}$`}
4040
onKeyUp={this.handleOnChange}
41+
style={{ width: this.getMaximumBoxWidth() + "ch" }}
4142
aria-label={`${this.props.type} sensor input ${this.props.axisLabel}`}
4243
/>
4344
<span className="sliderArea">
@@ -71,6 +72,15 @@ class InputSlider extends React.Component<ISliderProps, any, any> {
7172
);
7273
}
7374

75+
private getMaximumBoxWidth = () => {
76+
return (
77+
Math.max(
78+
this.props.minValue.toString().length,
79+
this.props.maxValue.toString().length
80+
) + 2
81+
);
82+
};
83+
7484
private handleOnChange = (event: any) => {
7585
const validatedValue = this.validateRange(this.updateValue(event));
7686
const newSensorState = this.writeMessage(validatedValue);

0 commit comments

Comments
 (0)