posit-dev / posit-dev/py-shiny

Rendered datatable losses ability to select row with collapsing sidebar

Open
#1,104 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

When outputting a dataframe via ui.output_data_frame and specifying row_selection_mode, a row in the datatable can be selected. However, when pairing with a sidebar, the user's ability to select a row is lost after collapsing or expanding the sidebar. Ability to select row only returns when app is refreshed

Current Version:

Python: 3.10.13
Shiny: 0.6.0

Steps to recreate (via example below)

  1. Launch app
  2. Select row in datatable. Row is indicated selected
  3. Collapse sidebar. Selected row is not longer selected. User cannot select a new row

Example

from shiny import App, Inputs, Outputs, Session, reactive, render, ui
import pandas as pd
df = pd.DataFrame({
    'A': ['foo', 'foo', 'foo', 'foo', 'bar', 'bar', 'bar', 'bar'],
    'B': ['one', 'one', 'two', 'two', 'one', 'one', 'two', 'two'],
    'C': ['small', 'large', 'large', 'small', 'small', 'small', 'large', 'small'],
    'D': [1, 2, 2, 3, 3, 4, 5, 6],
    'E': [2, 4, 5, 5, 6, 6, 8, 9]
})

app_ui = ui.page_fluid(
    ui.layout_sidebar(
        ui.sidebar(
            ui.input_slider("n", "N", min=0, max=100, value=20),
            title="A title",
        ),
        ui.output_data_frame("tbl_out"),
        style="min-height: 100vh;"
    )
)

def server(input: Inputs, output: Outputs, session: Session):
    
    @render.data_frame
    def tbl_out():
        return render.DataTable(
            df,
            row_selection_mode="single"
        )


app = App(app_ui, server)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided app using ui.output_data_frame, render.DataTable, row_selection_mode="single", and ui.layout_sidebar. Start by tracing how selection behaves when the sidebar collapses or expands; done means the selected row remains selected and a new row can be selected without refreshing the app.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.