Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog sidebar active item is not highlighted #5563

Closed
4 of 5 tasks
zmogas opened this issue Sep 13, 2021 · 1 comment · Fixed by #5571
Closed
4 of 5 tasks

Blog sidebar active item is not highlighted #5563

zmogas opened this issue Sep 13, 2021 · 1 comment · Fixed by #5571
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@zmogas
Copy link

zmogas commented Sep 13, 2021

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io
  • I have read the console error message carefully (if applicable)

Description

Blog section, left sidebar menu. On hover it highlights items, when clicked (blog page opened), highlight disappears.

Highlight still works in 2.0.0-beta.0 version, but all later versions - no.
We use latest docusaurus version: 2.0.0-beta.6. Using default preset-classic theme and double blog sections.

Have you read the Contributing Guidelines on issues?

Yes.

Steps to reproduce

(Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

Tried adding second blog section there. But failed. Copying my docusaurus configuration did not help. Sandbox configuration complained.)

Downgraded my used version to 2.0.0-beta.0, left sidebar highlight started working. Upgraded to 2.0.0-beta.6 - styles adjusted and active item highlight does not work.

Expected behavior

When clicking on blog item, it should remain active.

Actual behavior

Sidebar items highlight only on hover.

If I run docusaurus in local environment, highlight works. When I build and serve - highlight does not work. docusaurus site blog shows everything correctly.

I see problem in CSS declaration. Primary (highlighted) color is override with color-base. Order is important. Or active class value should include !important, then later declaration will not override.
Active item link has two classes: item-link and item-link-active. Both styles are merged. And both declare color. Later overrides first declaration.

See screenshot with active item selected:
Docusaurus-blog-sidebar-active-not-highlighted

https://docusaurus.io/blog/ in final css file first is declared sidebarItemLink, then sidebarItemLinkActive. The same order is when I run local development version. When I build, css classes are renamed and swapped places.

Your environment

One blog is configured via presets:

  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          routeBasePath: '/',
          path: 'docs',
          sidebarPath: require.resolve('./sidebars.js')
        },
        blog: {
          showReadingTime: true,
          blogDescription: `${envConfig.title} Blog`,
          blogTitle: 'Blog',
          blogSidebarCount: 'ALL',
          feedOptions: {
            type: 'all'
          }
        },

another blog is configured via plugins:

  plugins: [
    [
      '@docusaurus/plugin-content-blog',
      {
        id: 'changelog',
        routeBasePath: 'changelog',
        path: './changelog',
        showReadingTime: false,
        blogDescription: `${envConfig.title} Changelog`,
        blogTitle: 'Changelog',
        blogSidebarCount: 'ALL',
        blogSidebarTitle: 'All changelogs',
        feedOptions: {
          type: 'all',
          title: `${envConfig.title} Changelog`,
          description: `${envConfig.title} Changelog`
        }
      }
    ],

I did not install separate blog plugin, just reusing built-in from @docusaurus/preset-classic.

@zmogas zmogas added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 13, 2021
@lex111
Copy link
Contributor

lex111 commented Sep 15, 2021

@zmogas thanks for the bug report, will be fixed in the PR #5571.

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants