-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix: Don't load fit text front end scripts on the editor. #72842
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: Don't load fit text front end scripts on the editor. #72842
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @vmroc. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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: 0 B Total Size: 2.38 MB ℹ️ View Unchanged
|
Co-authored-by: jorgefilipecosta <[email protected]> Co-authored-by: oandregal <[email protected]>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: f337f03 |
This PR fixes an issue where the FitText frontend script (
fit-text-frontend.js) was incorrectly being enqueued and loaded in the block editor when editing posts that contain blocks with thefitTextattribute enabled. It had no big impact has the script does not do anything on the editor (the classes the script searches are not there) but still it's useless bytes we are sending.We are enqueuing using exactly the same pattern as in other blocks, like file. image, or form I suspect in some of theses cases the front end script is also loading on the editor when it is non needed, something we can try to improve after.
Testing Instructions
1. Verify E2E tests pass
Run the FitText e2e tests:
All tests should pass, including the new test "should not load frontend script when editing a saved post with fit text".
2. Verify the fix prevents the issue
Revert the fix to see the failure:
Run the e2e test again:
npm run test:e2e -- test/e2e/specs/editor/blocks/fit-text.spec.js -g "should not load frontend script"The test should now fail, demonstrating that without the fix, the frontend script loads in the editor.
Restore the fix:
3. Manual verification (optional)
Add a temporary alert for visual confirmation:
Add this line at the end of
packages/block-editor/src/utils/fit-text-frontend.js(after line 84):Test with this PR's changes:
Test on trunk (without fix):
git checkout trunkVerify fit text still works, on this branch on both the editor and front end.
** Test with customizer **
Use a theme with customizer support like "Twenty Sixteen", add post with fit text, and then open the customizer navigate to that post and verify fit text still works.