Skip to content

Commit

Permalink
Merge pull request #30 from jembi/CU-86byxgr9x_Mapper-Expression-prev…
Browse files Browse the repository at this point in the history
…iew-doesnt-work-until-space-is-added-after-the-expression

fx: rendering issue with the expression preview
  • Loading branch information
drizzentic authored Jul 4, 2024
2 parents 04c52d8 + c28c0c7 commit 0367b1e
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import {
Button,
Stack,
Expand Down Expand Up @@ -48,6 +48,16 @@ export function AddExpressionDialog() {
}
}

useEffect(() => {
// Assuming renderPreview uses the expression state internally
const preview = renderPreview();
if (typeof preview === 'string' && preview.startsWith('Error')) {
setPreviewValue("Error! Invalid expression.");
} else {
setPreviewValue(preview.toString());
}
}, [expression]);

return (
<>
<Button
Expand Down Expand Up @@ -84,7 +94,6 @@ export function AddExpressionDialog() {
type="text"
onChange={(e) => {
setExpression(e.target.value);
setPreviewValue(renderPreview().toString());
}}
fullWidth
required
Expand Down

0 comments on commit 0367b1e

Please sign in to comment.