0

I am creating a shiny app in python that has a file input component near the end of the page with some text at the beginning of the page. I've found that clicking to upload a file with file input component causes the whole app to scroll to the top of the app if one needs to scroll down to see the file input component. Is there a way to not have the app automatically scroll to the top of the page when the button to upload a file is clicked? There is an issue on GitHub about this (https://github.com/rstudio/shiny/issues/3327), but the proposed solutions are for R and I'm not sure if it can be directly translated to Python.

Many thanks.

Here is a very simple example app.py that will reproduce the problem when run in https://shinylive.io/py/examples/.

from shiny import App, render, ui

app_ui = ui.page_fluid(
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.br(),
    ui.input_file("file1", "Clicking this button will cause the screen to scroll up "),        
)


def server(input, output, session):
    @output
    @render.text
    def txt():
        return f"n*2 is {input.n() * 2}"


app = App(app_ui, server)
Jan
  • 2,245
  • 1
  • 2
  • 16

0 Answers0