Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title and description fields within the post editor do not trigger the save function as expected, also infinite loop on editor page related to nav.tsx #380

Open
erreib opened this issue Jan 10, 2024 · 4 comments · May be fixed by #387

Comments

@erreib
Copy link

erreib commented Jan 10, 2024

Editing the title or description fields within the post editor do not seem to trigger the save function as expected. Maybe there is an issue with the debounce timer set in editor.tsx? Editing the NovelEditor triggers the save as expected.

image

@erreib
Copy link
Author

erreib commented Jan 11, 2024

I solved this in my local version by adding a debounce timer within editor.tsx and used it for updating the title and description fields:
image
image
image

Is this a valid approach to fixing this, or would it be better to somehow get the debounce timer included in the NovelEditor instead of creating another one?

EDIT: I see now this is definitely not a valid approach since it causes an infinite loop, I will continue trying to fix.

@erreib
Copy link
Author

erreib commented Jan 11, 2024

So actually, it looks like the infinite loop might be occurring on the main demo site as well
image
Is this happening for anyone else?

@erreib erreib changed the title Title and description fields within the post editor do not trigger the save function as expected Title and description fields within the post editor do not trigger the save function as expected, also infinite loop on editor page Jan 11, 2024
@erreib erreib changed the title Title and description fields within the post editor do not trigger the save function as expected, also infinite loop on editor page Title and description fields within the post editor do not trigger the save function as expected, also infinite loop on editor page related to nav.tsx Jan 11, 2024
@erreib
Copy link
Author

erreib commented Jan 11, 2024

So after a little bit more investigation it looks like there's an issue with this useEffect in the nav.tsx. Commenting it out seemed to fix the infinite loop but I'm not really proficient enough to understand what the useEffect was doing.
image

@wallawe
Copy link

wallawe commented Feb 8, 2024

Thank you! I commented out the entire post/[id] page and it was still happening and I was thoroughly puzzled.

Edit: the quickest fix without changing any functionality is to change the dependency array:

  useEffect(() => {
    console.log("segments", segments);
    if (segments[0] === "post" && id) {
      getSiteFromPostId(id).then((id) => {
        setSiteId(id);
      });
    }
  }, [segments[0], id]);

Notice how I'm using segments[0] instead of segments because segments is an array (object) which gets returned from useSelectedLayoutSegments and thus the useEffect is running indefinitely because it's always a new object, even if the contents in it is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants