-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Navigation: Update deps for the useEffect that creates navigation menus #47912
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to keep this line, otherwise hasResolvedDraftNavigationMenus doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just not check if navigation menus are resolved? We only need them because
Is there another way? Like wait for this when creating the default title instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably but i'm not sure how to do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so actually - we also need to check if draft navigations are created because navigation we create is a draft. If I remove the check for
hasResolvedDraftNavigationMenus
then two get created.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we call createNavigationMenu we do it with an empty title and there is a hook
useGenerateDefaultNavigationTitle
where we alreadt check that we loaded all drafts already so we can assign the correct number.That means this guard here is kinda pointless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you pass in the
isCreatingNavigationMenu
status of thecreateNavigationMenu
from theedit
component? That way we have a way of telling whether the conversion is in progress. That might help us block the 2nd menu because it gives a true status of the progress of the event we care about - namely: whether we are already creating a navigation.Relying on various resolved states is surely prone to error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean that. I mean that
hasResolvedDraftNavigationMenus
andhasResolvedNavigationMenus
are only needed here as deps because we check for them in the effect - butcreateNavigationMenu
which is the only result of the effect ALSO checks them - it seems they're not needed. And if they're not needed we don't needdraftNavigationMenus
either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove them then the problem comes back, so I think they are needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work. After the new navigation is created, the status is reset to
idle
, but the block is still dirty as the new (draft) navigation hasn't yet loaded, so the effect gets triggered again, and we end up in a loop creating endless new menus.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work, because although
createNavigationMenu
does check the status of those dependencies, it happens after we callcreateNavigationMenu
, so the useEffect that is checking whether the blocks are in a dirty state will continue to be called.