Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/resources/projects/website/templates/sidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
// may be displayed in different locations, so this will determine where to display the tools
// "logo", "title", "search", "fallthrough"

let hasLogo = sidebar.logo.light || sidebar.logo.dark;

let toolsLocation;
// Under the title if that will be displayed
if (sidebar.title && !navbar) {
toolsLocation = "title";
} else if (sidebar.logo) {
} else if (sidebar.logo.light || sidebar.logo.dark) {
toolsLocation = "logo";
} else if (sidebar.search && sidebar.search !== "overlay") {
toolsLocation = "search";
Expand All @@ -32,9 +34,9 @@
}
%>

<% if (sidebar.logo || (sidebar.title && !navbar)) { %>
<div class="pt-lg-2 mt-2 <%= alignCss %> sidebar-header<%= sidebar.logo && sidebar.title ? ' sidebar-header-stacked' : '' %>">
<% if (sidebar.logo) { %>
<% if (hasLogo || (sidebar.title && !navbar)) { %>
<div class="pt-lg-2 mt-2 <%= alignCss %> sidebar-header<%= hasLogo && sidebar.title ? ' sidebar-header-stacked' : '' %>">
<% if (hasLogo) { %>
<a href="<%- sidebar['logo-href'] || '/index.html' %>" class="sidebar-logo-link">
<% if (sidebar.logo.light) { %>
<img src="<%- sidebar.logo.light.path %>" alt="<%- sidebar.logo.light.alt || '' %>" class="sidebar-logo light-content py-0 d-lg-inline d-none"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.quarto/
**/*.quarto_ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
project:
type: website

website:
title: "Issue 13506 - No Logo"
navbar:
left:
- text: "Section A"
href: index.qmd
- text: "Section B"
href: page2.qmd
sidebar:
- title: "Section A"
contents:
- index.qmd
- title: "Section B"
contents:
- page2.qmd

format:
html:
theme: cosmo
24 changes: 24 additions & 0 deletions tests/docs/smoke-all/website-sidebar/issue-13506-no-logo/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Section A"
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'nav.navbar a.nav-link[href$="index.html"].active'
- 'nav.navbar a.nav-link[href$="page2.html"]:not(.active)'
-
- 'a.sidebar-logo-link'
---

## Section A

This is Section A. When NO logo is configured in the sidebar, the navbar active
state should work correctly. The "Section A" navbar item should be active on this page.

The bug (issue #13506): After PR #12996, `sidebar.logo` was normalized to
`{light: undefined, dark: undefined}`, making `if(sidebar.logo)` always true.
This created empty `<a class="sidebar-logo-link">` elements that interfered with
the navbar active state detection logic.

See also: [Section B](page2.qmd)
20 changes: 20 additions & 0 deletions tests/docs/smoke-all/website-sidebar/issue-13506-no-logo/page2.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: "Section B"
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'nav.navbar a.nav-link[href$="page2.html"].active'
- 'nav.navbar a.nav-link[href$="index.html"]:not(.active)'
-
- 'a.sidebar-logo-link'
---

## Section B

This is Section B. The "Section B" navbar item should be active on this page,
demonstrating that the navbar active state detection works correctly without
empty logo links interfering.

See also: [Section A](index.qmd)
Loading