Skip to content

Commit a240e2d

Browse files
authored
Merge pull request #2109 from AnnMarieW/dropdown-maxHeight
Dropdown max height
2 parents 565de53 + ebc60ef commit a240e2d

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
44

55
## [UNRELEASED]
66

7+
### Added
8+
- [#2109](https://github.com/plotly/dash/pull/2109) Add `maxHeight` to Dropdown options menu.
9+
710
### Fixed
811
- [#2102](https://github.com/plotly/dash/pull/2102) Fix bug as reported in [dash-labs #113](https://github.com/plotly/dash-labs/issues/113) where files starting with `.` were not excluded when building `dash.page_registry`.
912
- [#2098](https://github.com/plotly/dash/pull/2098) Accept HTTP code 400 as well as 401 for JWT expiry

components/dash-core-components/src/components/Dropdown.react.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ Dropdown.propTypes = {
142142
*/
143143
optionHeight: PropTypes.number,
144144

145+
/**
146+
* height of the options dropdown.
147+
*/
148+
maxHeight: PropTypes.number,
149+
145150
/**
146151
* Defines CSS styles which will override styles previously set.
147152
*/
@@ -218,6 +223,7 @@ Dropdown.defaultProps = {
218223
multi: false,
219224
searchable: true,
220225
optionHeight: 35,
226+
maxHeight: 200,
221227
persisted_props: ['value'],
222228
persistence_type: 'local',
223229
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.dash-dropdown .Select-menu-outer {
22
z-index: 1000;
33
}
4+
5+
.dash-dropdown .Select-menu, .Select-menu-outer {
6+
max-height: none;
7+
}

components/dash-core-components/src/fragments/Dropdown.react.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const RDProps = [
2929
'placeholder',
3030
'disabled',
3131
'optionHeight',
32+
'maxHeight',
3233
'style',
3334
'className',
3435
];

components/dash-core-components/tests/integration/dropdown/test_visibility.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,19 @@ def test_ddvi001_fixed_table(dash_duo):
4545
dash_duo.percy_snapshot("dcc.Dropdown dropdown overlaps table fixed rows/columns")
4646

4747
assert dash_duo.get_logs() == []
48+
49+
50+
def test_ddvi002_maxHeight(dash_duo):
51+
app = Dash(__name__)
52+
app.layout = Div(
53+
[Dropdown([str(i) for i in range(100)], "1", id="dropdown", maxHeight=800)]
54+
)
55+
56+
dash_duo.start_server(app)
57+
58+
dash_duo.find_element("#dropdown").click()
59+
dash_duo.wait_for_element("#dropdown .Select-menu-outer")
60+
61+
dash_duo.percy_snapshot("dcc.Dropdown dropdown menu maxHeight 800px")
62+
63+
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)