From 51570dfd703b449fed39286531f7e56679b41611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 8 Apr 2020 15:35:55 -0400 Subject: [PATCH 1/5] don't scroll menu into view --- src/dash-table/components/CellDropdown/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dash-table/components/CellDropdown/index.tsx b/src/dash-table/components/CellDropdown/index.tsx index 30ae7a184..d772970f5 100644 --- a/src/dash-table/components/CellDropdown/index.tsx +++ b/src/dash-table/components/CellDropdown/index.tsx @@ -43,6 +43,7 @@ export default class CellDropdown extends PureComponent { onChange={(newValue: any) => { onChange(newValue ? newValue.value : newValue); }} + scrollMenuIntoView={false} onOpen={this.handleOpenDropdown} options={dropdown} placeholder={''} From c7a36c0b69432770a6a898ceafb327305a336956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 8 Apr 2020 15:38:19 -0400 Subject: [PATCH 2/5] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b311679b7..e937e3c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] +### Fixed +- [#732](https://github.com/plotly/dash-table/pull/732) Fix a bug where opening a dropdown scrolled +the table down its last row + ## [4.6.2] - 2020-04-01 ### Changed - [#713](https://github.com/plotly/dash-table/pull/713) Update from React 16.8.6 to 16.13.0 From 66b59a2ae4f2c934f17d4798e2ad10de9f101af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 8 Apr 2020 16:02:24 -0400 Subject: [PATCH 3/5] - undo fix - new test (will fail, to pass after the fix added back) --- .../components/CellDropdown/index.tsx | 1 - tests/selenium/conftest.py | 5 ++ tests/selenium/test_dropdown.py | 51 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/selenium/test_dropdown.py diff --git a/src/dash-table/components/CellDropdown/index.tsx b/src/dash-table/components/CellDropdown/index.tsx index d772970f5..30ae7a184 100644 --- a/src/dash-table/components/CellDropdown/index.tsx +++ b/src/dash-table/components/CellDropdown/index.tsx @@ -43,7 +43,6 @@ export default class CellDropdown extends PureComponent { onChange={(newValue: any) => { onChange(newValue ? newValue.value : newValue); }} - scrollMenuIntoView={false} onOpen={this.handleOpenDropdown} options={dropdown} placeholder={''} diff --git a/tests/selenium/conftest.py b/tests/selenium/conftest.py index 6d0d29f15..950282ab8 100644 --- a/tests/selenium/conftest.py +++ b/tests/selenium/conftest.py @@ -101,6 +101,11 @@ def is_focused(self): return "focused" in cell.get_attribute("class").split(" ") + def open_dropdown(self): + cell = self.get() + + cell.find_element_by_css_selector(".Select-arrow").click() + class DataTableColumnFacade(object): @preconditions(_validate_id, _validate_mixin, _validate_col_id, _validate_state) diff --git a/tests/selenium/test_dropdown.py b/tests/selenium/test_dropdown.py new file mode 100644 index 000000000..313313204 --- /dev/null +++ b/tests/selenium/test_dropdown.py @@ -0,0 +1,51 @@ +import dash + +from dash_table import DataTable + + +def get_app(): + app = dash.Dash(__name__) + + columns = [ + dict(id="a", name="a"), + dict(id="b", name="b"), + dict(id="c", name="c", presentation="dropdown"), + ] + + app.layout = DataTable( + id="table", + columns=columns, + dropdown=dict( + c=dict( + options=[ + dict(label="Value-0", value=0), + dict(label="Value-1", value=1), + dict(label="Value-2", value=2), + dict(label="Value-3", value=3), + ] + ) + ), + data=[dict(a=i, b=i, c=i % 4) for i in range(100)], + editable=True, + ) + + return app + + +def get_page_offset(test): + return test.driver.execute_script( + "return document.body.getBoundingClientRect().top;" + ) + + +def test_drpd001_no_scroll(test): + test.start_server(get_app()) + + target = test.table("table") + cell = target.cell(1, "c") + + yOffset = get_page_offset(test) + + cell.open_dropdown() + + assert get_page_offset(test) == yOffset From 7462ad2c4fbdcadb8318d3e67875b28431dff592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Wed, 8 Apr 2020 16:10:36 -0400 Subject: [PATCH 4/5] Add back the fix --- src/dash-table/components/CellDropdown/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dash-table/components/CellDropdown/index.tsx b/src/dash-table/components/CellDropdown/index.tsx index 30ae7a184..d772970f5 100644 --- a/src/dash-table/components/CellDropdown/index.tsx +++ b/src/dash-table/components/CellDropdown/index.tsx @@ -43,6 +43,7 @@ export default class CellDropdown extends PureComponent { onChange={(newValue: any) => { onChange(newValue ? newValue.value : newValue); }} + scrollMenuIntoView={false} onOpen={this.handleOpenDropdown} options={dropdown} placeholder={''} From d98b5d11501695cd1a79186acde88f834ccb41c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Rivet?= Date: Thu, 16 Apr 2020 11:00:01 -0400 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34e081722..5fa2d1e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - [#722](https://github.com/plotly/dash-table/pull/722) Fix a bug where row height is misaligned when using fixed_columns and/or fixed_rows - [#728](https://github.com/plotly/dash-table/pull/728) Fix copy/paste on readonly cells -the table down its last row - [#724](https://github.com/plotly/dash-table/pull/724) Fix `active_cell` docstring: clarify optional nature of the `row_id` nested prop -- [#732](https://github.com/plotly/dash-table/pull/732) Fix a bug where opening a dropdown scrolled +- [#732](https://github.com/plotly/dash-table/pull/732) Fix a bug where opening a dropdown scrolled the table down its last row ## [4.6.2] - 2020-04-01 ### Changed