diff --git a/CHANGELOG.md b/CHANGELOG.md index 574d84f00..3e13c4aa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - [#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 - [#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 the table down its last row - [#731](https://github.com/plotly/dash-table/pull/731) Fix a bug where `data=None` and `columns=None` caused the table to throw an error ## [4.6.2] - 2020-04-01 diff --git a/src/dash-table/components/CellDropdown/index.tsx b/src/dash-table/components/CellDropdown/index.tsx index 538638ffa..d5f7dc402 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={''} diff --git a/tests/selenium/conftest.py b/tests/selenium/conftest.py index 8baa8b519..7df3297c8 100644 --- a/tests/selenium/conftest.py +++ b/tests/selenium/conftest.py @@ -106,6 +106,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