Skip to content

Make active tab/section distinguishable in navbar #1321

Closed

Description

@batpigandme

Currently, there's no way to tell which "tab" is active in the main navbar. This should be somehow identifiable (e.g. bold or different color).

Activity

  1. jjallaire commented on May 31, 2022

    @jjallaire
    Collaborator

    There are some things to work through here mostly what the definition of an active tab is (as tabs can target individual files, index pages in directories, sidebars, etc. and/or can have drop-down menus that target all of the same). I've built sites that use a simple directory prefix heuristic but Quarto sites will all vary considerably in their topology so it won't be that simple in most cases.

    I'm pretty confident we can come up with an automated heuristic here but it will require some thought and tweaking to get right -- will work on this after the v1.0 release window.

  2. self-assigned this
    on Jul 8, 2022
  3. added this to the Future milestone on Jul 8, 2022
  4. modified the milestones: Future, v1.1 on Aug 5, 2022
  5. jjallaire commented on Aug 6, 2022

    @jjallaire
    Collaborator

    It looks like we do actually attempt to latch the active nav item here (which amount to adding the active class as well as
    setting aria-current=page):

    https://github.com/quarto-dev/quarto-cli/blob/main/src/project/types/website/website-navigation.ts#L405-L422

    The visual appearance is in turn controlled by these variables:

    https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/formats/html/bootstrap/dist/scss/_nav.scss#L74-L79

    In the default and cosmo themes (which is what generate from quarto create-website) there is no visual distinguisher for active however for many other themes there is.

    I'm going to close this issue as the system appears to have correct logic for this state (we can then separately debate whether we want to override the bootstrap default for latched visual appearance -- I will say that in a couple of themes I tried it was very subtle, possibly because too heavy a treatment creates more visual noise on the navbar than people want). If it has potential to be overdone and somewhat a matter of taste/preference I'd be more inclined for this to be something resolved by themes/variables rather than a default we set.

  6. ecomodeller commented on Nov 19, 2024

    @ecomodeller

    It seems like this feature is broken.

    An example from the Quarto gallery is https://nbdev.fast.ai/tutorials/tutorial.html

    In this example the active class as well as the aria-current attribute is set on the "Get started" anchor, instead of the "Tutorial".

    <li class="nav-item">
        <a class="nav-link active" href="[../getting_started.html](https://nbdev.fast.ai/getting_started.html)" aria-current="page"> 
    <span class="menu-text">Get Started</span></a>
      </li>  
      <li class="nav-item">
        <a class="nav-link" href="[../tutorials/tutorial.html](https://nbdev.fast.ai/tutorials/tutorial.html)"> 
    <span class="menu-text">Tutorial</span></a>
      </li>

    Is the path ../tutorials/tutorial.html too complicated?

    This is confusing, any hints on a workaround on how to disable this?

    In some themes it might not be visually apparent, but I suppose still a problem for accessibility, in some cases it is subtle:
    Image

    Mkdocs material uses a more explicit approach to indicate the current tab

    Example from FastAPI docs
    Image

  7. mcanouil commented on Nov 19, 2024

    @mcanouil
    Collaborator

    Please open a new issue following the issue template eventually referencing this one.
    Thank you!

  8. ecomodeller commented on Nov 19, 2024

    @ecomodeller

    Please open a new issue following the issue template eventually referencing this one. Thank you!

    @mcanouil I have opened a new issue where I have tried to create a minimal reproducible example.

    I suspect the sidebar is causing some issue, without the sidebar it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions