Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabulator Patch always resets scroll position #5000

Open
Wijnko opened this issue Jun 1, 2023 · 0 comments
Open

Tabulator Patch always resets scroll position #5000

Wijnko opened this issue Jun 1, 2023 · 0 comments
Labels
component: tabulator Related to the Tabulator widget type: bug Something isn't correct or isn't working
Milestone

Comments

@Wijnko
Copy link

Wijnko commented Jun 1, 2023

ALL software version info

Panel 1.0.4
Bokeh 3.1.1
MacOS 12.6
Chrome Version 113.0.5672.126

Description of expected behavior and the observed behavior

Expected:
Scroll position is untouched on data patching

Observed:
Table scrolls to top after every data patch

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import pandas as pd
pn.extension('tabulator')

sample_data = pd.DataFrame({'Number': [0]*10})

last_row_index = sample_data.index[-1]
last_row_value = sample_data['Number'].loc[last_row_index]

table = pn.widgets.Tabulator(sample_data, height=200)

button = pn.widgets.Button(name='Increase the value of the last row')

def increase_last_number(event):
    global last_row_value
    last_row_value += 1
    table.patch({'Number': [(last_row_index, last_row_value)]})

button.on_click(increase_last_number)

pn.Column(
    table,
    button
).servable()

Screenshots or screencasts of the bug in action

panel_tabulator_pitch_scroll_issue

Note:

By changing the updateOrAddData method and removing one line in /panel/models/tabulator.ts, I was able to get the expected behaviour:

Changes:

The _lastVerticalScrollbarTopPosition variable never gets set to a value other than 0 on Initialisation (https://github.com/holoviz/panel/blob/v1.0.4/panel/models/tabulator.ts#L290)

  updateOrAddData(): void {
    // To avoid double updating the tabulator data
    if (this._tabulator_cell_updating)
      return

    let data = transform_cds_to_records(this.model.source, true)
    this.tabulator.updateOrAddData(data)
    this.postUpdate()
  }

Result:

panel_tabulator_patch_fixed

@philippjfr philippjfr added type: bug Something isn't correct or isn't working component: tabulator Related to the Tabulator widget labels Jun 1, 2023
@philippjfr philippjfr modified the milestones: v1.0.5, v1.1.0, v1.1.1 Jun 1, 2023
@philippjfr philippjfr modified the milestones: v1.1.1, v1.2.0 Jun 22, 2023
@philippjfr philippjfr modified the milestones: v1.2.0, v1.2.1 Jul 10, 2023
@philippjfr philippjfr modified the milestones: v1.2.1, v1.2.2 Jul 25, 2023
@Hoxbro Hoxbro modified the milestones: v1.2.2, v1.2.3 Sep 4, 2023
@philippjfr philippjfr modified the milestones: v1.2.3, v1.2.4 Sep 18, 2023
@philippjfr philippjfr modified the milestones: v1.2.4, v1.3.0 Oct 9, 2023
@philippjfr philippjfr modified the milestones: v1.3.0, v1.3.1 Oct 23, 2023
@philippjfr philippjfr modified the milestones: v1.3.1, v1.3.2 Oct 31, 2023
@philippjfr philippjfr modified the milestones: v1.3.2, v1.4.0 Nov 22, 2023
@philippjfr philippjfr modified the milestones: v1.4.0, v1.4.x Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabulator Related to the Tabulator widget type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

3 participants