-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: Fixed site-editor crashing when added front-page template and clicking more option #67500
Fix: Fixed site-editor crashing when added front-page template and clicking more option #67500
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Thanks for the PR!
Perhaps the original code should have been written like this:
const actions = [
...defaultActions,
...(shouldShowSetAsHomepageAction ? [setAsHomepageAction] : []),
];
However, I think it would be clearer to use the push
method, as done in this PR. Let's get some feedback from the contributors who worked on #65426.
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.
Thank you!
Thanks for fixing this! |
Co-authored-by: Mayank-Tripathi32 <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: oandregal <[email protected]>
Co-authored-by: Mayank-Tripathi32 <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: oandregal <[email protected]>
resolves #67498
What?
This PR modifies how the array for actions is constructed by using default action destructuring and conditionally pushing values to the array.
Why?
The previous implementation was adding an empty array at the end of the actions list when the condition for shouldShowSetAsHomepageAction was false. This caused issues, particularly in the "More Options" menu, where an empty action was being passed and leading to a crash. This PR resolves that by ensuring that only valid actions are added to the array.
How?
To address this issue, I changed the following snippet:
Old Code:
The previous code resulted in adding an empty array at the end when the condition shouldShowSetAsHomepageAction was false.
New Code:
This change ensures that if shouldShowSetAsHomepageAction is false, the setAsHomepageAction is not pushed into the array, avoiding the empty array scenario and preventing the crash.
Testing Instructions