Skip to content

Commit

Permalink
Optimize logic when onlyIncludeCurrentPage is false.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed May 4, 2022
1 parent 74dbd1c commit d703b72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/table-of-contents/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export default function TableOfContentsEdit( {
// Get the client ids of all blocks in the editor.
const allBlockClientIds = getClientIdsWithDescendants();

// Calculate the page (of a paginated post) this block is part of.
// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.
let tocPage = 1;

if ( isPaginated ) {
if ( isPaginated && onlyIncludeCurrentPage ) {
// We can't use getBlockIndex because it only returns the index
// relative to sibling blocks.
const tocIndex = allBlockClientIds.indexOf( clientId );
Expand Down

0 comments on commit d703b72

Please sign in to comment.