Skip to content

Commit 1047bc6

Browse files
committed
feat: bonus: add parsing error highlighting
1 parent 971b57c commit 1047bc6

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/shared/widget-plugin-filtering/src/controllers/input/NumberInputController.ts

+2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class NumberFilterController {
8888
disposers.push(
8989
autorun(() => {
9090
this.input1.setValue(this.filter.arg1.displayValue);
91+
this.input1.setIsValid(this.filter.arg1.isValid);
9192
this.input2.setValue(this.filter.arg2.displayValue);
93+
this.input2.setIsValid(this.filter.arg2.isValid);
9294
})
9395
);
9496

packages/shared/widget-plugin-filtering/src/controls/input/InputWithFilters.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function InputWithFiltersComponent<Fn extends AllFunctions>(props: InputC
1111
} = props;
1212
return (
1313
<div
14-
className={classNames("filter-container", props.className)}
14+
className={classNames("filter-container", props.className, { "has-error": !input1.isValid })}
1515
data-focusindex={props.tabIndex ?? 0}
1616
style={props.styles}
1717
>
@@ -24,6 +24,7 @@ export function InputWithFiltersComponent<Fn extends AllFunctions>(props: InputC
2424
/>
2525
)}
2626
<input
27+
aria-invalid={input1.isValid ? undefined : true}
2728
aria-label={props.screenReaderInputCaption}
2829
className={classNames("form-control", { "filter-input": props.adjustable })}
2930
disabled={props.disableInputs}

packages/shared/widget-plugin-filtering/src/stores/input/InputStore.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { makeObservable, observable, action } from "mobx";
22

33
export class InputStore {
44
value: string;
5+
isValid = true;
56

67
constructor(init = "") {
78
this.value = init;
89

910
makeObservable(this, {
1011
value: observable,
12+
isValid: observable,
1113
setValue: action,
1214
onChange: action
1315
});
@@ -17,6 +19,10 @@ export class InputStore {
1719
this.value = value;
1820
}
1921

22+
setIsValid(value: boolean): void {
23+
this.isValid = value;
24+
}
25+
2026
onChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
2127
this.setValue(event.target.value);
2228
};

0 commit comments

Comments
 (0)