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

Error selecting cell in virtualized table #447

Closed
kottmast opened this issue May 28, 2019 · 10 comments
Closed

Error selecting cell in virtualized table #447

kottmast opened this issue May 28, 2019 · 10 comments
Labels
dash-type-bug Something isn't working as intended regression Worked in a previous version

Comments

@kottmast
Copy link

Clicking to select a cell that is "below the fold" throws: TypeError: Cannot read property '1' of undefined, where '1' is the column index of the cell that is clicked.

Simple example...

dash_table.DataTable(
            id='table',
            data=df.to_dict('records'),
            columns=[{'id': c, 'name': c} for c in df.columns],
            editable=False,
            filtering=True,
            sorting=True,
            sorting_type="multi",
            pagination_mode=False,
            virtualization=True
)

When the data is loaded and the table is displayed, clicking a cell highlights that cell to indicate it is selected. If you then scroll down and click to select a new cell, the error is thrown. Full stack trace:

react-dom@16.8.6.min.js?v=0.24.0&m=1554834449:117 TypeError: Cannot read property '1' of undefined
    at e.value (type.ts:35)
    at e.value (type.ts:83)
    at data.ts:32
    at e.getDataEdges (memoizer.ts:7)
    at EdgeFactory.tsx:28
    at e.memoizedCreateEdges (memoizer.ts:7)
    at e.value (EdgeFactory.tsx:138)
    at index.tsx:18
    at t.value (index.tsx:458)
    at ce (react-dom@16.8.6.min.js?v=0.24.0&m=1554834449:98)

The property it tries to read appears to be the column index of the cell that was clicked, ie. if you click in the 5th column the error will be "Cannot read property '4' of undefined".

After that the table either disappears or becomes unresponsive. I discovered this while trying to add a callback to do something with the selected cells. There is no apparent server-side error and the callback executes successfully, so the error seems to happen after the callback is executed.

Versions:
dash 0.43.0
dash-table 3.7.0
Chrome 74.0

@kottmast
Copy link
Author

I just downgraded to dash_table==3.6.0 and do not see the error so it seems to be a regression introduced in 3.7.0.

@Marc-Andre-Rivet
Copy link
Contributor

@kottmast Thanks for reporting this. Investigating.

@Marc-Andre-Rivet Marc-Andre-Rivet added regression Worked in a previous version dash-type-bug Something isn't working as intended labels May 29, 2019
@vivekvs1
Copy link

Having a similar error but for a different scenario. Assigning 'data' for a table based on selected_data of another table is throwing the same error. Like @kottmast has mentioned, it works fine when I downgraded to dash_table==3.6.0

@wvwhome
Copy link

wvwhome commented Jun 19, 2019

Also error: ⛑️
Cannot read property '2' of undefined
with 3.7.0. but I'm also using 'row_id' which is only in 3.7.0. Stuck.

@Marc-Andre-Rivet
Copy link
Contributor

@kottmast @wvwhome I've reproduced this issue in dash-table==3.7.0 by selecting a cell and arrowing down until 2 cells past the last visible cell. At that point the error you described occurs.

I've been unable to reproduce this example with dash==1.0.2 (dash-table==4.0.2) - with the props having changed a bit, using:

import dash
import dash_table
import pandas as pd

app = dash.Dash(__name__)

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/Emissions%20Data.csv').reset_index()
df['Emission'] = df['Emission'].map(lambda x: '{0:.2f}'.format(x))

app.layout = dash_table.DataTable(
        id='table',
        data=df.to_dict('records'),
        columns=[{'id': c, 'name': c} for c in df.columns],
        editable=False,
        filter_action="native",
        sort_action="native",
        sort_mode="multi",
        page_action="none",
        virtualization=True
)

if __name__ == '__main__':
    app.run_server(debug=True)

This seems to have been fixed by accident during the 3.x -> 4.0 refactoring.

Can you confirm that the behavior is ok on your side with the latest version? I've opened a follow up issue here to add a test for this scenarios.

@action-ghost
Copy link

action-ghost commented Aug 28, 2019

Can we using any solutions like “disable select action” to fix this?Because of we just can't upgrade data-table version immediately,we need to keep use dash_table==3.7.0 for some feature we used.

@Marc-Andre-Rivet
Copy link
Contributor

Tests have been added to make sure this behavior does not break in the future (#535).

Upgrading to dash>=1.0.2 (dash-table>=4.0.2) should fix the issue.

@action-ghost What 3.7.0 feature do you use that is not available in 4.x?

The main issue raised in the 4.0 release was that we dropped the the hidden columns feature. That feature has been restructured into new props & UI, and is available again in 4.1 and above.

@Marc-Andre-Rivet
Copy link
Contributor

Closing as fixed and tested. There is way to alter the behavior in 3.7.0 in such a way as to avoid the error.

@rp2532
Copy link

rp2532 commented Jan 10, 2020

I think this could be a related issue -
#436

@emilmajkowski
Copy link

Hello,
It seems like the issue with "Cannot read properties of undefined (reading '')" when virtualization = True is back
dash-table 5.0.0
dash 2.0.0

Could you please review and fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dash-type-bug Something isn't working as intended regression Worked in a previous version
Projects
None yet
Development

No branches or pull requests

7 participants