From bb8ce47c2b95b17306bbfa4418f29b28d6233f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Thu, 12 Sep 2019 15:20:02 -0400 Subject: [PATCH 1/3] get the right index mapping for virtualized table --- src/dash-table/handlers/cellEvents.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dash-table/handlers/cellEvents.ts b/src/dash-table/handlers/cellEvents.ts index e3f3e9875..c39048457 100644 --- a/src/dash-table/handlers/cellEvents.ts +++ b/src/dash-table/handlers/cellEvents.ts @@ -121,7 +121,7 @@ export const handleChange = (propsFn: () => ICellFactoryProps, idx: number, i: n } = propsFn(); const c = visibleColumns[i]; - const realIdx = virtualized.indices[idx]; + const realIdx = virtualized.indices[idx - virtualized.offset.rows]; if (!c.editable) { return; @@ -152,7 +152,7 @@ export const handleEnter = (propsFn: () => ICellFactoryProps, idx: number, i: nu } = propsFn(); const c = visibleColumns[i]; - const realIdx = virtualized.indices[idx]; + const realIdx = virtualized.indices[idx - virtualized.offset.rows]; setState({ currentTooltip: { @@ -179,7 +179,7 @@ export const handleMove = (propsFn: () => ICellFactoryProps, idx: number, i: num } = propsFn(); const c = visibleColumns[i]; - const realIdx = virtualized.indices[idx]; + const realIdx = virtualized.indices[idx - virtualized.offset.rows]; if (currentTooltip && currentTooltip.id === c.id && currentTooltip.row === realIdx) { return; From 6ea7620140263b4ec426385444f9d72014054d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Thu, 12 Sep 2019 16:03:31 -0400 Subject: [PATCH 2/3] virtualized change/enter/move test --- tests/cypress/tests/standalone/scrolling_test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/cypress/tests/standalone/scrolling_test.ts b/tests/cypress/tests/standalone/scrolling_test.ts index 5ed8377bf..9c6532de7 100644 --- a/tests/cypress/tests/standalone/scrolling_test.ts +++ b/tests/cypress/tests/standalone/scrolling_test.ts @@ -50,7 +50,21 @@ variants.forEach(([mode, flavors]) => { cy.get('.row-1').scrollTo(0, 0); DashTable.getSelectedCells().should('have.length', 6); + }); + + it('can edit cell', () => { + DashTable.toggleScroll(false); + DashTable.getCell(0, 0).click(); + DashTable.toggleScroll(true); + + cy.get('.row-1').scrollTo(0, 1000); + cy.wait(1000); + + DashTable.getCell(10, 1).click(); + DOM.focused.type(`Edited${Key.Enter}`); + DOM.focused.type(`${Key.ArrowUp}`); + DOM.focused.should('have.value', 'Edited'); }); }); }); \ No newline at end of file From 51d7804a7aed90eb1db8b007c62e6774c18544e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Thu, 12 Sep 2019 16:06:07 -0400 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d5b618d8..67065be74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). [#18](https://github.com/plotly/dash-table/issues/18) - Fix row selection vertical and horizontal alignment +[#583](https://github.com/plotly/dash-table/issues/583) +- Fix regression when editing the content of a cell in a scrolled virtualized table + ## [4.2.0] - 2019-08-27 ### Added [#317](https://github.com/plotly/dash-table/issues/317)