BookManager generates links that don't get is-active class

Created on 17 November 2020, about 4 years ago
Updated 24 August 2023, over 1 year ago

Problem/Motivation

When building and styling a book navigation block, I noticed that unlike regular menus, I was missing the class "is-active". In fact the attribute "data-drupal-link-system-path" is also missing and other problems could be caused by this. The LinkGenerator service only adds these to links when the Url has the option "set_active_class" set to TRUE (defaults to FALSE). The BookManager service create the links and adds a ['localized_options']['set_active_class'] to TRUE, I suspect it's legacy code.

Steps to reproduce

Enable Book, create a book outline, verify the output of book navigation.

Proposed resolution

I added the option to the Url object, it fixes the issue.

Remaining tasks

  1. Review if this is the best approach, I am not very knowledgeable on the link generation system internals.
  2. Write a test.

Release notes snippet

Fixes missing "is-active" class in Book navigation menus.

๐Ÿ› Bug report
Status

Closed: duplicate

Version

9.1

Component
Bookย  โ†’

Last updated 4 days ago

  • Maintained by
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States @pwolanin
Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada franz Montrรฉal

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nkraft

    Adding a note for anyone else falling down the same rabbit hole I just did.
    https://www.drupal.org/project/ideas/issues/3265493 ๐Ÿ“Œ [Policy] Move book to contrib in Drupal 11 Fixed --
    Managers of Core have decided to deprecate the module, and remove it from Core as of Drupal 11 -- which means the OTHER related ticket/report, referred to in the previous comment, decided to drop their patch entirely from being applied to Book going forward. I'm hoping my clarification here might help others that come after me to this thread :)

Production build 0.71.5 2024