Problem/Motivation

The mobile version of the Table of Contents appears on the Desktop version of pages and Desktop version appears on mobile

Steps to reproduce

Install version 2.0.1. of TOC API and go to a page in screen size larger than 768px and one that utilizes the TOC feature. It shows the Desktop version of the TOC and the mobile dropdown right underneath. Going to the mobile version of the page will show both TOCs as well.

Proposed resolution

Not totally sure. I rolled my version back to 2.0.0. and its working correctly. It seems like something isn't picking up the responsive styles correctly and leaving them off the page.

Remaining tasks

User interface changes

API changes

Data model changes

Drupal Version: 10.5.4

Let me know if there is anything else I can be of assistance with. Thanks!

Issue fork toc_api-3553887

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thanksneco created an issue. See original summary.

thanksneco’s picture

Issue summary: View changes
revija’s picture

Hello, this error occurs when the toc_api module makes three calls to renderRoot() within a render flow, which is no longer valid in Drupal 10.2+.

This breaks the render context and causes the error:

A stray renderRoot() invocation is causing bubbling of attached assets to break.

Affected file: web/modules/contrib/toc_api/src/TocBuilder.php

Before (line 92):
$html = Html::normalise($this->renderer->renderRoot($build));

After:
$html = Html::normalise($this->renderer->render>($build));

Before (line 130):
$html = Html::normalise($this->renderer->renderRoot($build));

After:
$html = Html::normalise($this->renderer->render($build));

Before (line 163):
return $this->renderer->renderRoot($build);

After:
return $this->renderer->render($build);

Edit the file, then clear the caches and let us know.

jurgenhaas’s picture

I ran into this as well, not related to mobile or desktop, though. I just figured that no libraries get called anymore. And when I revert that change from render to renderRoot, then the problem is fixed. This was introduced in #2905420: Fix empty render context but that doesn't seem to be the correct solution. I'm creating an MR to revert this.

jurgenhaas’s picture

Title: Mobile TOC appearing on desktop » Libraries not loaded since renderRoot is used instead of render
Version: 2.0.1 » 2.0.x-dev
Priority: Normal » Major
Status: Active » Needs review

Not sure what the fix for the other issue is, but for now I needed to revert the change to that libraries get loaded again.

seattlehimay’s picture

Thank you for posting Jugenhaas!

I was seeing my default TOCs change to numbered lists with a strange pull down menu.

I manually applied your reversion, and it fixed the issues I was seeing on D10.5.4/TOC-API 2.0.1/TOC Filter 8.x-2.4. Back to a normal TOC.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Yes this works to get the library to load. Thank you all!

papagrande’s picture

I was getting fatal errors on views RSS feeds. The reversion fixed it for me. Thanks, @jurgenhaas.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joelpittet’s picture

Thank you! One less patch woo!

joelpittet’s picture

This would be a good to drop a release as it’s a major fix

joseph.olstad’s picture

FYI: I've tagged this and put it into an RC1 release
2.0.2-rc1

https://www.drupal.org/project/toc_api/releases/2.0.2-rc1

Feedback is appreciated!

joseph.olstad’s picture

Looked at the usage stats, decided to tag 2.0.2 now, thanks!

https://www.drupal.org/project/toc_api/releases/2.0.2

ericgsmith’s picture

Thanks Joseph, much appreciated

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.