Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/config/robotconfig/SwerveConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
number={config.backLeft.x}
maxWidthCharacters={8}
titleTooltip="X coordinate of back modules (negative)"
valid={(number) => number.defaultUnitMagnitude <= 0}

Check failure on line 40 in src/components/config/robotconfig/SwerveConfigPanel.tsx

View workflow job for this annotation

GitHub Actions / TypeScript compiler

'number.defaultUnitMagnitude' is possibly 'undefined'.

Check failure on line 40 in src/components/config/robotconfig/SwerveConfigPanel.tsx

View workflow job for this annotation

GitHub Actions / TypeScript compiler

'number.defaultUnitMagnitude' is possibly 'undefined'.
/>

<ExpressionInput
Expand Down
8 changes: 7 additions & 1 deletion src/components/input/ExpressionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type ExpressionInputProps = {
titleTooltip?: string;
/** Maximum width of the number input, in monospace characters */
maxWidthCharacters?: number;
/** A function to verify the validity of an input. */
valid?: ((thing: IExpressionStore) => boolean);
};

type State = {
Expand Down Expand Up @@ -137,7 +139,11 @@ class Input extends Component<ExpressionInputProps, State> {
className={
styles.Number +
(showNumberWhenDisabled ? " " + styles.ShowWhenDisabled : "") +
(this.getValid() ? " " : " " + styles.Invalid)
(this.getValid() &&
(this.props.valid == undefined ||
this.props.valid(this.props.number))
? " "
: " " + styles.Invalid)
}
style={{
minWidth: `${characters}ch`,
Expand Down
Loading