Skip to content

Commit 13a3d02

Browse files
committed
Error to user when back mod x is positive
Resolves #1202 Signed-off-by: Jade Turner <[email protected]>
1 parent 5800d1a commit 13a3d02

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/components/config/robotconfig/SwerveConfigPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SwerveConfigPanel extends Component<Props, State> {
3737
number={config.backLeft.x}
3838
maxWidthCharacters={8}
3939
titleTooltip="X coordinate of back modules (negative)"
40+
valid={(number) => number.defaultUnitMagnitude <= 0}
4041
/>
4142

4243
<ExpressionInput

src/components/input/ExpressionInput.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type Props = {
2121
titleTooltip?: string;
2222
/** Maximum width of the number input, in monospace characters */
2323
maxWidthCharacters?: number;
24+
/** A function to verify the validity of an input. */
25+
valid: ((thing: IExpressionStore) => boolean) | undefined;
2426
};
2527

2628
type State = {
@@ -137,7 +139,11 @@ class Input extends Component<Props, State> {
137139
className={
138140
styles.Number +
139141
(showNumberWhenDisabled ? " " + styles.ShowWhenDisabled : "") +
140-
(this.getValid() ? " " : " " + styles.Invalid)
142+
(this.getValid() &&
143+
(this.props.valid == undefined ||
144+
this.props.valid(this.props.number))
145+
? " "
146+
: " " + styles.Invalid)
141147
}
142148
style={{
143149
minWidth: `${characters}ch`,

0 commit comments

Comments
 (0)