Exclude hidden elements from the table of content

Created on 27 June 2023, over 1 year ago

Problem/Motivation

At the moment the toc.js seems to recognize also headings which are hidden on the page with display none. This can be a bit troublesome because first of all the headings are not visible when trying to scroll the page but it also breaks the scrolling when it tries to scroll to an element which is not in the DOM.

Steps to reproduce

1. Configure the table of content to recognize all headings on a page.
2. Create an element which is using display none to hide the heading.

At the moment the hidden heading is included in the table of content. I would suggest that either we don't include hidden elements in the table of content by default or add an option to exclude them in the settings.

Proposed resolution

It should be possible to check with JS if the element is currently hidden and exclude the title from the table of contents.

Remaining tasks

Create the JS functionality and possibly unit tests.

User interface changes

Optionally make this setting configurable in the content type settings for the table of contents.

API changes

None.

Data model changes

Optionally add the new setting in the configuration schema.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇫🇮Finland heikkiy Oulu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024