Skip to content

Commit 498c90b

Browse files
committed
Fix plotly#2653: unexpected behaviour of Dropdown
dcc.Dropdown has inconsistent layout flow compared to other common input components. The layout bug is normalised with CSS style display set to inline-block.
1 parent c847882 commit 498c90b

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React, {Component, lazy, Suspense} from 'react';
33
import dropdown from '../utils/LazyLoader/dropdown';
4+
import './css/Dropdown.css';
45

56
const RealDropdown = lazy(dropdown);
67

@@ -14,11 +15,36 @@ const RealDropdown = lazy(dropdown);
1415
* constrained for space. Otherwise, you can use RadioItems or a Checklist,
1516
* which have the benefit of showing the users all of the items at once.
1617
*/
17-
export default class Dropdown extends Component {
18+
export default class Dropdown extends Component {
1819
render() {
20+
const { style, className, ...props } = this.props;
1921
return (
2022
<Suspense fallback={null}>
21-
<RealDropdown {...this.props} />
23+
<RealDropdown
24+
{...props}
25+
className={`dash-dropdown ${className || ''}`}
26+
styles={{
27+
control: (provided) => ({
28+
...provided,
29+
display: 'inline-block',
30+
verticalAlign: 'middle',
31+
width: style?.width || '300px', // Default width
32+
}),
33+
menu: (provided) => ({
34+
...provided,
35+
maxHeight: 'none',
36+
display: 'inline-block',
37+
width: style?.width || '300px', // Default width
38+
verticalAlign: 'middle',
39+
}),
40+
menuOuter: (provided) => ({
41+
...provided,
42+
maxHeight: 'none',
43+
zIndex: 1000,
44+
width: style?.width || '300px', // Default width
45+
}),
46+
}}
47+
/>
2248
</Suspense>
2349
);
2450
}
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
.dash-dropdown .Select-menu-outer {
2-
z-index: 1000;
3-
max-height: none;
1+
.dash-dropdown .Select-control {
2+
display: inline-block;
3+
width: 300px;
4+
vertical-align: middle;
5+
margin-left: 785px;
46
}
57

68
.dash-dropdown .Select-menu {
79
max-height: none;
10+
display: inline-block;
11+
width: 300px;
12+
vertical-align: middle;
13+
}
14+
15+
.dash-dropdown .Select-menu-outer {
16+
z-index: 1000;
17+
max-height: none;
18+
width: 300px;
19+
margin-left: 785px;
820
}

0 commit comments

Comments
 (0)