mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-08 01:15:49 +02:00
fix: use the new method (#5894)
This PR adds the new setValuesWithRecord method to the deletion of values. In addition, we'll auto save when using the undo button aswell.
This commit is contained in:
parent
f7b285d340
commit
ebd673e9fc
@ -127,16 +127,11 @@ export const ConstraintAccordionEdit = ({
|
|||||||
|
|
||||||
setLocalConstraint(previousChange);
|
setLocalConstraint(previousChange);
|
||||||
setConstraintChanges((prev) => prev.slice(0, prev.length - 1));
|
setConstraintChanges((prev) => prev.slice(0, prev.length - 1));
|
||||||
|
autoSave(previousChange);
|
||||||
};
|
};
|
||||||
|
|
||||||
const recordChange = (localConstraint: IConstraint) => {
|
const autoSave = (localConstraint: IConstraint) => {
|
||||||
setConstraintChanges((prev) => [...prev, localConstraint]);
|
if (onAutoSave) {
|
||||||
|
|
||||||
if (
|
|
||||||
onAutoSave &&
|
|
||||||
localConstraint.values &&
|
|
||||||
localConstraint.values.length > 0
|
|
||||||
) {
|
|
||||||
onAutoSave(localConstraint);
|
onAutoSave(localConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +140,11 @@ export const ConstraintAccordionEdit = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const recordChange = (localConstraint: IConstraint) => {
|
||||||
|
setConstraintChanges((prev) => [...prev, localConstraint]);
|
||||||
|
autoSave(localConstraint);
|
||||||
|
};
|
||||||
|
|
||||||
const setContextName = useCallback((contextName: string) => {
|
const setContextName = useCallback((contextName: string) => {
|
||||||
setLocalConstraint((prev) => {
|
setLocalConstraint((prev) => {
|
||||||
const localConstraint = cleanConstraint({
|
const localConstraint = cleanConstraint({
|
||||||
@ -231,7 +231,7 @@ export const ConstraintAccordionEdit = ({
|
|||||||
const valueCopy = [...localConstraint.values!];
|
const valueCopy = [...localConstraint.values!];
|
||||||
valueCopy.splice(index, 1);
|
valueCopy.splice(index, 1);
|
||||||
|
|
||||||
setValues(valueCopy);
|
setValuesWithRecord(valueCopy);
|
||||||
},
|
},
|
||||||
[localConstraint, setValues],
|
[localConstraint, setValues],
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user