quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.54k stars 291 forks source link

Search cannot be disable in navbar #9905

Open mcanouil opened 3 weeks ago

mcanouil commented 3 weeks ago

It's not possible to disable the search button/bar when in its default location, namely navbar.

The search will still appear on the right of the navbar.

website:
  search: 
    location: navbar
  navbar:
    search: false

As a comparison, the same for sidebar works as expected:

website:
  search: 
    location: sidebar
  sidebar:
    search: false

Originally posted by @mcanouil in https://github.com/quarto-dev/quarto-cli/discussions/9836#discussioncomment-9692676

cderv commented 3 weeks ago

So the aim is to control the search box inclusion at the navbar or sidebar level and not at the top level website.search ?

This is the issue here, is this correct understanding ?

mcanouil commented 3 weeks ago

Possibly, at least the documentation implies that it is possible. If you cannot disable at the navbar level, then it's odd to have search: true (if it can take true, I expect false to be valid) and the below description in the documentation.

Include a search box (true or false). Note that if there is already a search box on the top navigation bar it won’t be displayed on the sidebar.

Source: https://quarto.org/docs/websites/website-navigation.html#side-navigation

The main issue to me is that if you want to disable search, from the documentation, it is very likely, a user will try:

website:
  navbar:
    search: false
cderv commented 3 weeks ago

It seems there is indeed a difference in processing

For sidebar https://github.com/quarto-dev/quarto-cli/blob/0a548a67cd4a2094c4b5c71b15bb53ee1b18c2cf/src/project/types/website/website-navigation.ts#L1015-L1020

for navbar https://github.com/quarto-dev/quarto-cli/blob/0a548a67cd4a2094c4b5c71b15bb53ee1b18c2cf/src/project/types/website/website-navigation.ts#L1230-L1235

So in the former, if sidebar.search is set to false, it deactive search , and global setting is ignored For the latter, the value of navbar.search does not seem important at all.

I believe it has been lost here: https://github.com/quarto-dev/quarto-cli/commit/0b86f2219857df6e657eda3a62581e48276c8de7#diff-2399e32434824d82d99e49170925185608bab491654180e0426afae839d61ef0L764

Previously, the navbar.search was the way to activate it, before the website.search.location was implemented.

And the exact same issue has been fixed for sidebar.search in there: 0ba4ad1ae1e6831a68d79db9737966b6fb5de7f6

So probably we should do the same for navbar.