Skip to content

[BUG] scrollTo Jumps the Scroll Bar #3085

Closed
@georgiossalon

Description

@georgiossalon
  • pip list
dash                 2.18.2
dash_ag_grid         31.2.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
  • Browser, Version and OS

    • OS: win11
    • Browser chrome
    • Version 130.0.6723.119 (Offizieller Build) (64-Bit)

Describe the bug

Adjusting the scrollTo and selecting a row makes the scroll bar to jump back to the position set in my callback. The callback is getting triggered only once though in the beginning.

Expected behavior

Since the callback is not getting triggered when selecting a row, the scroll bar should stay where I manually scrolled.

Code

import dash_ag_grid as dag
from dash import Dash, html, Input, Output
import pandas as pd


app = Dash(__name__)

df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
)


columnDefs = [
    {"headerName": "Row", "valueGetter": {"function": "params.node.rowIndex"}}
] + [{"field": c} for c in df.columns]

app.layout = html.Div(
    [
        dag.AgGrid(
            id="grid-scroll-to-start",
            columnDefs=columnDefs,
            rowData=df.to_dict("records"),
            dashGridOptions={'rowSelection': 'single', 'animateRows': False}
        ),
    ]
)

@app.callback(
    Output('grid-scroll-to-start', 'scrollTo'),
    Input('grid-scroll-to-start', 'rowData')
)
def handle_scroll_to(rowData):
    #dummy logic
    row = rowData[100]
    return {'data': row}


if __name__ == "__main__":
    app.run(debug=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions