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 collection pagination: add min height to avoid infinite number #59241

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const DEFAULT_CATEGORY = {
slug: 'all',
name: _x( 'All', 'font categories' ),
};

const MIN_WINDOW_HEIGHT = 500;

function FontCollection( { slug } ) {
const requiresPermission = slug === 'google-fonts';

Expand Down Expand Up @@ -118,7 +121,8 @@ function FontCollection( { slug } ) {

// NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px
// The height of each font family item is 61px.
const pageSize = Math.floor( ( window.innerHeight - 417 ) / 61 );
const windowHeight = Math.max( window.innerHeight, MIN_WINDOW_HEIGHT );
const pageSize = Math.floor( ( windowHeight - 417 ) / 61 );
const totalPages = Math.ceil( fonts.length / pageSize );
const itemsStart = ( page - 1 ) * pageSize;
const itemsLimit = page * pageSize;
Expand Down
Loading