Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 9ba3d19

Browse files
marcogallo566jasonLaster
authored andcommitted
Expression syntax errors are cleared on save (#5678)
* [Expression] syntax errors are cleared on save Modified 1 file: src/components/SecondaryPanes/Expression.js * [Expression] syntax errors are cleared on save Modified 1 file: src/actions/expressions.js * [Expression] syntax errors are cleared on save Modified 1 file: src/components/SecondaryPanes/Expression.js * [Expression] syntax errors are cleared on save Modified 1 file: src/components/SecondaryPanes/Expression.js * Lint cleanup
1 parent 26e90b1 commit 9ba3d19

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/actions/expressions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ export function addExpression(input: string) {
3434
return;
3535
}
3636

37+
const expressionError = await parser.hasSyntaxError(input);
38+
3739
const expression = getExpression(getState(), input);
3840
if (expression) {
3941
return dispatch(evaluateExpression(expression));
4042
}
4143

42-
const expressionError = await parser.hasSyntaxError(input);
4344
dispatch({ type: "ADD_EXPRESSION", input, expressionError });
4445

4546
const newExpression = getExpression(getState(), input);

src/components/SecondaryPanes/Expressions.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,22 @@ class Expressions extends Component<Props, State> {
121121
) => {
122122
e.preventDefault();
123123
e.stopPropagation();
124+
124125
this.props.updateExpression(this.state.inputValue, expression);
125126
};
126127

127128
handleNewSubmit = async (e: SyntheticEvent<HTMLFormElement>) => {
129+
const { inputValue } = this.state;
128130
e.preventDefault();
129131
e.stopPropagation();
130-
this.props.addExpression(this.state.inputValue);
131-
this.setState({ editing: false, editIndex: -1, inputValue: "" });
132+
133+
this.props.clearExpressionError();
134+
await this.props.addExpression(this.state.inputValue);
135+
this.setState({
136+
editing: false,
137+
editIndex: -1,
138+
inputValue: this.props.expressionError ? inputValue : ""
139+
});
132140
};
133141

134142
renderExpression = (expression: Expression, index: number) => {

0 commit comments

Comments
 (0)