Skip to content

Commit

Permalink
Clear deleted object state after successful save
Browse files Browse the repository at this point in the history
  • Loading branch information
elektronaut committed Jun 7, 2024
1 parent a1360f4 commit 51478ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/assets/builds/pages_core/admin-dist.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app/assets/builds/pages_core/admin-dist.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions app/javascript/components/PageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export default function PageForm(props: Props) {
});
};

const clearDeletedObjects = () => {
filesState.setDeleted([]);
imagesState.setDeleted([]);
};

const handleSubmit = (evt: React.MouseEvent) => {
evt.preventDefault();
let method = postJson;
Expand All @@ -105,6 +110,7 @@ export default function PageForm(props: Props) {
if (response.errors && response.errors.length > 0) {
errorToast("A validation error prevented the page from being saved.");
} else {
clearDeletedObjects();
noticeToast("Your changes were saved");
}
})
Expand Down

0 comments on commit 51478ef

Please sign in to comment.