Skip to content

Fix state bug in multipage navigation item retrieval - #52

Merged
RobjS merged 1 commit into
mainfrom
fix/multipage-in-page-nav-state-bug
Jul 24, 2026
Merged

Fix state bug in multipage navigation item retrieval#52
RobjS merged 1 commit into
mainfrom
fix/multipage-in-page-nav-state-bug

Conversation

@RobjS

@RobjS RobjS commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a bug in the multipage navigation functionality by ensuring that repeated calls to MultipageInPageNavigation::getItems() return consistent results.

Before: getItems() would duplicate the items set if called more than once on the same instance. This could result in navigation rendering incorrectly.
Now: it always only returns the single correct set of items.

This PR was co-authored with CoPilot.

How to test

  1. Spin up a site that uses the parent/child structure for long reads
  2. Checkout the main branch of this plugin
  3. Modify the LongReadPlugin\Navigation::getItems() method so it repeatedly gets the in-page items, e.g.
public static function getItems(): array
	{
		if (!isset(static::$chapterNavigation) || !isset(static::$inPageNavigation)) {
			return [];
		}
		$chapterNavItems = static::$chapterNavigation->getItems();
		$inPageNavItems = static::$inPageNavigation->getItems();
		$inPageNavItems = static::$inPageNavigation->getItems();
		$inPageNavItems = static::$inPageNavigation->getItems();
...
  1. Confirm that this results in duplicate sets of in-page navigation items
  2. Checkout this branch and make the same modification to that file
  3. Confirm that navigation still renders correctly in the front-end, and no other changes are visible.

@RobjS
RobjS force-pushed the fix/multipage-in-page-nav-state-bug branch from 827079b to 2f5e8ae Compare July 24, 2026 13:03
Before: `getItems()` would duplicate the items set if called more than once on the same instance. This could result in navigation rendering incorrectly.
Now: it always only returns the single correct set of items.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RobjS
RobjS force-pushed the fix/multipage-in-page-nav-state-bug branch from 2f5e8ae to bae2025 Compare July 24, 2026 13:37
@RobjS
RobjS marked this pull request as ready for review July 24, 2026 13:37

@sbrody sbrody left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works locally

@RobjS
RobjS merged commit 1e92747 into main Jul 24, 2026
2 checks passed
@RobjS
RobjS deleted the fix/multipage-in-page-nav-state-bug branch July 24, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants