Skip to content

Fix #3030: Selection for DataTable cleared with custom action settings#3669

Open
Francisc0C wants to merge 1 commit intoplotly:devfrom
Francisc0C:dev
Open

Fix #3030: Selection for DataTable cleared with custom action settings#3669
Francisc0C wants to merge 1 commit intoplotly:devfrom
Francisc0C:dev

Conversation

@Francisc0C
Copy link
Copy Markdown

This PR fixes issue #3030 and two analogous bugs in derivedPropsHelper.ts.

In derivedPropsHelper.ts, selected rows may be invalidated when sorting, filtering or changing pages, while using custom action settings.

Invalidation happens when sorting, filtering or pagination actions are set to custom and their values change.
The code does not check whether the same callback also provides a new selected_rows value.

Because invalidation runs inside a setTimeout(..., 0), when a callback updates both selection and sorting, filtering or pagination, the selection briefly appears and clears, causing a visible "flicker".

The fix adds a check before invalidating the selection. We verify whether selected_rows actually changed in the current callback, if it did not change, the selection is preserved preventing incorrect invalidation.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Add a check in derivedPropsHelper.ts to verify if selected_rows changed before invalidating the selection
    • Add a test case covering the selection invalidation bug
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

@camdecoster
Copy link
Copy Markdown
Contributor

Thanks for the PR! Our team will take a look and follow up. At first glance, I see the Dash Table tests are failing. Could you take a look and see if there are any updates that need to be made?

…ettings

In derivedPropsHelper.ts, selected rows may be invalidated when sorting,
filtering or changing pages, while using custom action settings.

Invalidation happens when sorting, filtering or pagination actions are
set to custom and their values change.

The code does not check wether the same callback also provides a new
selected_rows value.

Because invalidation runs inside a setTimeout(..., 0), when a callback
updates both selection and sorting, filtering or pagination, the
selection briefly appears and clears, causing a visible "flicker".

To fix this, before invalidating the selection, we simply have to
check wether selected_rows actually changed in the current callback.

The selection is only cleared if it did not change, preventing the
invalidation of the sent selection.
@Francisc0C
Copy link
Copy Markdown
Author

Hi! The only Dash Table test that was failing is the same one that was already failing in the project version from a few weeks ago when I created the PR (commit ffff73d).

I’ve now rebased onto the current dev branch, so hopefully the tests should no longer fail.

Apologies for the multiple force pushes, I accidentally rebased my commit onto master instead of dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants