Skip to content

Commit

Permalink
fix: manage aggregate label separately to not trigger validation (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChibiBlasphem authored Mar 5, 2025
1 parent 175ebac commit 03f1844
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export function AggregationEdit({
);
const currentScenario = useCurrentScenario();
const { validation, validate } = useAstValidationFetcher(currentScenario.id);
const [label, setLabel] = useState(aggregation.label ?? '');

useEffect(() => {
if (validation) {
Expand All @@ -301,7 +302,7 @@ export function AggregationEdit({
}, [validation, dataModel]);

const handleSave = () => {
onSave(adaptAggregationAstNode(aggregation));
onSave(adaptAggregationAstNode({ ...aggregation, label }));
};

const handleChange = (agg: AggregationViewModel) => {
Expand Down Expand Up @@ -344,17 +345,10 @@ export function AggregationEdit({
type="text"
id="aggregation.label"
placeholder={t('scenarios:edit_aggregation.label_placeholder')}
value={aggregation.label}
onChange={(e) =>
handleChange({
...aggregation,
label: e.target.value,
errors: {
...aggregation.errors,
label: [],
},
})
}
value={label}
onChange={(e) => {
setLabel(e.target.value);
}}
borderColor={aggregation.errors.label.length > 0 ? 'redfigma-47' : 'greyfigma-90'}
/>
<EvaluationErrors
Expand Down

0 comments on commit 03f1844

Please sign in to comment.