Add option to hide single breadcrumb

Created on 14 March 2022, over 2 years ago
Updated 29 March 2024, 8 months ago

Problem/Motivation

First, thanks for the excellent module!

I am using this module on a site where:
1. We do not render the homepage breadcrumb
2. We render the current page as an unlinked breadcrumb

This means that on top-level pages there is a single breadcrumb that is not linked. My client does not want a single unlinked breadcrumb to appear.

Proposed resolution

Add a configuration option to hide breadcrumbs if there is a single unlinked breadcrumb.

Remaining tasks

- Phrase settings positively (use "remove" rather than "do not add")
- Expand test coverage to include new option

User interface changes

New form field

API changes

New config value

Data model changes

Add new option to schema

โœจ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States danflanagan8 St. Louis, US

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

Merge Requests

Comments & Activities

Not all content is available!

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

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

    The patch applies under 2.0.0-alpha0 and Drupal 10.1.1, but I would argue this should be more generic. Instead, there should be an option to hide breadcrumbs if only 1 item (linked or not) is present. This is typically "Home" for most people I would assume, and single item breadcrumbs don't solve much purpose.

    Could we just change this so it hides a single item, linked or not?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States danflanagan8 St. Louis, US

    Hi, @kevinquillen. The project I was using this patch on no longer uses menu_breadcrumb, so I no longer have any skin in the game. I haven't thought about this in a long time (March 2022!?!?) but I see a single unlinked breadcrumb as being particularly problematic.

    However, in the few seconds since typing that, it occurs to me that it is unlikely that a single site would have scenarios with a single unlinked breadcrumb on some pages while having a single linked breadcrumb on other pages. A given site would would presumably experience a single breadcrumb as always being linked or always being unlinked. Therefore, I think you're right that a more general "hide single breadcrumb" setting would offer the most value.

    I don't think I will personally update the patch, but you can feel free to re-purpose this issue for the more general "hide single breadcrumb" option.

    Cheers!

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States kevinquillen

    Here is an updated patch that hides the breadcrumb if it contains a single item, whether its linked or not.

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

    Because this analysis happens after Home is added (if that is selected), the presence of the home link makes the patch in #7 inapplicable to any page but the homepage. I tweaked the code to take into account if home has been added, so the breadcrumbs will only show if the total links are at least 3 (including HOME, self, and one other) or if home is not added, 2.

  • First commit to issue fork.
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Attaching interdiff to show changes between previous two patches.

    Let's switch to using Gitlab MRs over patches if you don't mind? ( Using Gitlab to contribute to Drupal โ†’ .)

    Let's also add this to the existing test coverage in tests/src/Functional/SettingsFormTest.php please.

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Thinking this might be better labelled as "Remove single items", to match the existing "Remove home" setting?

    (I find that when I encounter a setting phrased negatively (eg "Do not add single item"), and I see that the setting is currently FALSE, I can hear clapper boards flipping in my head as I try to calculate that if-not-do-not-add means do or don't do X. This is likely a me problem, but I think it can improve both comms and DX generally to prefer positively phrased statements!)

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    @dgroene I've added some additional tests which hopefully will help to clarify the expected behaviour. Please do continue working on this if you can!

    Take a look at https://git.drupalcode.org/issue/menu_breadcrumb-3269452/-/blob/3269452-... (and other tests in that directory) to see a test which can cover this behaviour. I'm sure it can be improved, hoping to give you a good start point - let's not presume it's 100% correct please :)

Production build 0.71.5 2024