-
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
Global Styles: Make Additional CSS button always work #68956
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. |
Size Change: -3 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
What?
This PR makes the Additional CSS button in the global styles work in all states.
Why?
The global styles sidebar screen switches automatically depending on the state of the canvas view, mainly through the
useEffect
hook here. Furthermore, the initial value of the canvas view isundefined
.The first time you click the Additional CSS button, the canvas view changes from
undefined
toglobal-styles-css
. TheuseEffect()
hook detects this change and navigates the global styles sidebar screens to CSS.After that, you press the back button and then click the Additional CSS button again. This time, the canvas view remains
global-styles-css
, souseEffect()
hook has no effect and the screen does not switch.How?
In the button's click event, I restored the deleted
goTo()
function. This ensures that the Additional CSS button always works, regardless of the state of the canvas view.Furthermore, I removed the similar code in the
useEffect()
hook to preventgoTo()
from being executed twice.Testing Instructions
Screenshots or screencast
03535722f05de68d15a5d488e829c115.mp4