pressbooks / pressbooks-book

McLuhan is the default book theme for Pressbooks.
https://pressbooks.org
GNU General Public License v3.0
20 stars 16 forks source link

Unable to link to anchors that are contained within collapsed headings in the webbook #251

Closed josieg closed 5 years ago

josieg commented 6 years ago

Prerequisites

Description

I have a book where I have turned on "collapse sections" in web theme options. In the backmatter, I have answers to all exercises in the book. I am trying to link each answer back to the exercise it corresponds with. But when an exercise is underneath a collapsed h1 heading, it just takes me to the beginning of the chapter instead of expanding the h1 heading to take me directly to what I am linking to.

Here is a book where I have this set up:

I tested this on Chrome, Firefox, and Edge.

Steps to Reproduce

  1. Turn on "Collapse sections" in web theme options.
  2. In one chapter, insert a H1 heading. Underneath the H1 heading, insert content with an anchor.
  3. In a second chapter, create a link to that anchor.
  4. Go to the web book and click the link you created in the second chapter.
  5. The link will take you to the right chapter, but will not expand the collapsed h1 to display the content that is being linked to.

Expected behavior: I expect to be taken directly to the content that I am linking to. I expect that if that content is underneath a collapsed h1 heading, that that section would expand.

Actual behavior: When I am navigating via link to content underneath a h1 heading (with "collapse headings" theme option turned on), I am taken to the beginning of the chapter instead of to exactly where I am linking to.

System Information

Book Info

Book ID: 173 Book URL: https://opentextbc.ca/physicalgeologyjosie/ Book Privacy: Public

Browser

Platform: Windows Browser Name: Chrome Browser Version: 68.0.3440.106 User Agent String: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

WordPress Configuration

Network URL: http://opentextbc.ca/ Network Type: Subdirectory Version: 4.9.7 Language: en_US WP_ENV: Not set WP_DEBUG: Disabled Memory Limit: 64M

Pressbooks Configuration

Version: 5.4.5 Book Theme: McLuhan Book Theme Version: 2.4.3 Root Theme: Aldine Root Theme Version: 1.4.1

Pressbooks Dependencies

Epubcheck: Installed Kindlegen: Installed xmllint: Installed PrinceXML: Installed Saxon-HE: Installed

Must-Use Plugins

hm-autoloader.php: n/a

Network Active Plugins

Akismet Anti-Spam: 4.0.8 Better WordPress Google XML Sitemaps: 1.4.1 CC Export for Pressbooks: 0.2.4 f5 Force SSL: 1.0.0 iThemes Security: 7.0.4 Openstax Import for Pressbooks: 1.2.4 Pressbooks: 5.4.5 Pressbooks Stats: 1.4.0 Textbooks for Pressbooks: 4.2.0 User Activation Keys: 4.6 WP-Piwik: 1.0.19

Book Active Plugins

Inactive Plugins

H5P: 1.10.3 mPDF for Pressbooks: 3.2.1 Relevanssi: 4.0.11 WP QuickLaTeX: 3.8.4

Server Configuration

PHP Version: 7.1.20 MySQL Version: 5.5.5 Webserver Info: Apache

PHP Configuration

Safe Mode: Disabled Memory Limit: 512M Upload Max Size: 500M Post Max Size: 500M Upload Max Filesize: 500M Time Limit: 60 Max Input Vars: 1000 URL-aware fopen: On (1) Display Errors: N/A

PHP Extensions

OPcache: Disabled XDebug: Disabled cURL: Supported cURL Version: 7.19.7 imagick: Installed xsl: Installed

josieg commented 2 years ago

Hi! It looks like a very similar issue is happening again. I've tested this on the KPU pressbooks instance to confirm.

Description

At BCcampus, we use same-page links and anchors so people can navigate between an image and it's long description in the webbook and export formats. However, when a webbook has "Collapse Headings" enabled and the anchor is inside a different heading section that is collapsed, nothing happens when the link is clicked.

One thing to note is that when I add the #id to the webbook URL and refresh the tab, the section does open. So the is some inconsistent behaviour here.

Steps to Reproduce

  1. Create a chapter with two Heading 1s.
  2. Under the second heading, create an anchor with a unique ID.
  3. Under the first heading, create a link to that anchor.
  4. Enable "Collapse headings" in web theme options.
  5. View the chapter in the webbook.
  6. Expand the 1st heading and click the link. Nothing happens.

What I expect to happen: When I click the link, I would expect the heading 1 that contains the anchor to expand and for me to be taken directly to that anchor.

Here is a chapter where I have been testing: https://kpu.pressbooks.pub/josiestestbook/chapter/chapter-1/