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

Font Library Pagination Footer JavaScript error: Uncaught RangeError: Invalid array length #59235

Closed
carolinan opened this issue Feb 21, 2024 · 4 comments · Fixed by #59241
Closed
Labels
[Feature] Font Library [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

I've been trying to find the best way to reproduce this issue for the past two days, and it doesn't always show up. I have not been able to pin point what exact conditions triggers the error.

When I open the Font Library and click on the tab panel "Install fonts", I see "The editor has encountered an unexpected error".
It happens both with and without fonts installed.

Here is the content from the "Copy Error" button:

RangeError: Invalid array length
    at PaginationFooter (http://localhost:8889/wp-includes/js/dist/edit-site.js?ver=9f909713a1d0e8a21a08:7452:20)
    at renderWithHooks (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:16315:20)
    at updateFunctionComponent (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:19598:22)
    at beginWork (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:21611:18)
    at beginWork$1 (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:27436:16)
    at performUnitOfWork (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:26567:14)
    at workLoopSync (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:26476:7)
    at renderRootSync (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:26444:9)
    at recoverFromConcurrentError (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:25860:22)
    at performSyncWorkOnRoot (http://localhost:8889/wp-includes/js/dist/vendor/react-dom.js?ver=18.2.0:26106:22)

And here is the log.
localhost-1708514725259.log

Step-by-step reproduction instructions

In the Site Editor, open the Font Library from the Styles > Typopgraphy panel and click on the tab panel "Install fonts"

Screenshots, screen recording, code snippet

No response

Environment info

6.5-beta2-57673 on Local , using the beta tester nightly
6.5-beta2-57671-src which is my current copy of wordpress-develop.
With and without Gutenberg trunk.
Tested on Twenty Twenty-Four and on a custom block theme that does not add any font families.

-Untested on 6.4.3.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@carolinan carolinan added [Type] Bug An existing feature does not function as intended [Feature] Font Library labels Feb 21, 2024
@carolinan
Copy link
Contributor Author

The pagination footer select list uses an array created from totalPages. But if I use console.log to print totalPages, I get Infinity.

See https://github.com/WordPress/gutenberg/blob/trunk/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js#L356

@t-hamano
Copy link
Contributor

I was also able to reproduce this problem. In the case I encountered, I got the exact same error when I narrowed down the height of the browser.

63d343e1c02606df2f18a7330214f07b.mp4

@pbking @matiasbenedetto, There may be a problem with the calculation of total pages.

const pageSize = Math.floor( ( window.innerHeight - 417 ) / 61 );
const totalPages = Math.ceil( fonts.length / pageSize );

@carolinan
Copy link
Contributor Author

Thank you for confirming.

@matiasbenedetto matiasbenedetto self-assigned this Feb 21, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 21, 2024
@matiasbenedetto matiasbenedetto moved this from 📥 Todo to 🏗️ In Progress in WordPress 6.5 Editor Tasks Feb 21, 2024
@matiasbenedetto matiasbenedetto removed their assignment Feb 21, 2024
@matiasbenedetto
Copy link
Contributor

A potential fix for this is ready to review: #59241

@matiasbenedetto matiasbenedetto moved this from 🏗️ In Progress to 🔎 Needs Review in WordPress 6.5 Editor Tasks Feb 21, 2024
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 6.5 Editor Tasks Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants