quarto-dev / quarto-dev/quarto-cli
When clicking on tab of panel-tabset, the page scrolls to the top
@cscheid is already working on this.
Since Dec 2, 2024.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
I'm developing a HTML page with Shiny server that will act as a dashboard. We decided to go with this design (instead of Quarto dashboard) due to some layout ideas that are easier to implement on this format.
Basically, it will consist of a top map, some text, and then some tabs (built using panel-tabset) to show specific content (see image below). Note that for simplicity of this example, I added the styles directly on the Quarto document, but on the original it goes in a separate css file.
I'm having a problem with the tabsets. Although it is looking as I expect, when a tab is clicked the page scroll to the top. This is not an appropriate behavior; what I would expect is that when the tab is clicked the page keep on the position that it is.
I tested in Google Chrome and Safari, and the problem occurs in both cases.
Could you please advice me on what might be causing this bug and if there is any workaround to avoid that?
I appreciate in advance your help.
How the example looks like:
Steps to reproduce
---
title: ""
format:
html:
theme: cosmo
page-layout: custom
include-in-header:
- text: |
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Mulish:ital,wght@0,200..1000;1,200..1000&display=swap" rel="stylesheet">
mainfont: Mulish
server: shiny
---
<style>
#content {
padding-right: 30px;
padding-left: 30px;
}
#siteTitle {
font-size: x-large;
color: #0277d4;
font-weight: 900;
padding-top: 20px;
padding-bottom: 20px;
}
</style>
::: {id='top'}
``` {r}
#| height: 300px
library(leaflet)
leaflet() |> addTiles(urlTemplate = "https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png") |>
setView(0, 0, zoom = 2)
```
:::
::: {id='content'}
```{r}
textOutput("siteTitle")
```
The atoll is comprised of four large coral islands which enclose a shallow lagoon; the group of islands is itself surrounded by a coral reef. Due to difficulties of access and the atoll's isolation, Aldabra has been protected from human influence and thus retains some 152,000 giant tortoises, the world's largest population of this reptile.
<br>
::: {.panel-tabset}
## Species
``` {r}
sliderInput("bins", "Number of bins:",
min = 1, max = 50, value = 30)
plotOutput("distPlot")
```
## Taxonomy
``` {r}
plotOutput("distPlot2")
```
:::
``` {r}
#| context: server
# load libraries
library(shiny)
library(dplyr)
dataset <- reactiveValues(d = NULL)
observe({
dataset$d <- rnorm(n = input$bins)
})
output$distPlot <-renderPlot({
plot(dataset$d)
})
output$distPlot2 <- renderPlot({
plot(dataset$d)
})
output$siteTitle <- renderText({
"Aldabra Atoll"
})
```
:::
Expected behavior
When the tab is clicked, the page position should be kept, so the user can view the content of the second tab without needing to scroll down.
Actual behavior
Every time the tab is clicked, the page scrolls to the top.
Your environment
- IDE: VSCode
- OS: macOS Sonoma 14.4.1
Quarto check output
Quarto 1.5.52
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.52
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/silas/Library/TinyTeX/bin/universal-darwin
Version: 2023
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.3
Path: /opt/homebrew/opt/python@3.12/bin/python3.12
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.3.1
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
knitr: 1.45
rmarkdown: 2.26
[✓] Checking Knitr engine render......OK
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.