Skip to content

Commit

Permalink
Hopefully fix a crash provoking bug
Browse files Browse the repository at this point in the history
Something was causing a crash when using the breadcrumb links
to navigate to another page in the path editing menu while
being in "edit mode" (i.e. in the process of adding a new page).
This resulted in a "Maximum update depth exceeded" error, crashing
the interface. The error hints at circular rendering dependendies,
but unfortunately I couldn't reproduce this myself.

But by attempting to do that I noticed another bug that may or
may not be related: The list of children was missing an entry.
I removed the code doing that, since it didn't seem to be necessary
anyway - this also removed a state setting call that might have
caused too many rerenders.
  • Loading branch information
owi92 committed Nov 7, 2024
1 parent 823a8e3 commit 45814db
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const NewTobiraPage = <T extends TobiraFormProps>({

const select = (page?: TobiraPage) => {
if (!page || !page.new) {
stopEditing();
setEditing(false);
}
if (!page || formik.values.selectedPage === page) {
formik.setFieldValue("selectedPage", undefined);
Expand Down Expand Up @@ -171,16 +171,6 @@ const NewTobiraPage = <T extends TobiraFormProps>({
select(newPage);
};

const stopEditing = () => {
if (editing) {
dispatch(setTobiraPage({
...currentPage,
children: currentPage.children.filter((_, idx) => idx !== currentPage.children.length - 1)
}));
}
setEditing(false);
};

const setPage = (
key: number,
e: React.ChangeEvent<HTMLInputElement>,
Expand Down

0 comments on commit 45814db

Please sign in to comment.