Skip to content

Commit ef6c623

Browse files
committed
The alignment of dropdown menu wrapper should take effect when the pullRight prop is specified
1 parent a264f4d commit ef6c623

6 files changed

+22
-22
lines changed

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,12 @@ btnStyle | One of:<br/>'default'<br/>'primary'<br/>'emphasis'<br/>'flat'<br/>'li
248248
noCaret | boolean | false | Whether to prevent a caret from being rendered next to the title.
249249
title | node | | Title content.
250250
disabled | boolean | false | Whether or not component is disabled.
251-
open | boolean | false | Whether or not the dropdown is visible.
252251

253252
#### DropdownMenu
254253

255254
Name | Type | Default | Description
256255
:--- | :--- | :------ | :----------
257256
componentClass | element | ul | A custom element for this component.
258-
open | boolean | false | Whether or not the dropdown is visible.
259-
pullRight | boolean | false | Align the menu to the right side of the dropdown toggle.
260257
onClose | function(event) | | A callback fired when the dropdown menu closes.
261258
onSelect | function(eventKey, event) | | A callback fired when a menu item is selected.
262259
rootCloseEvent | One of:<br/>'click'<br/>'mousedown' | | Which event when fired outside the component will cause it to be closed.
@@ -266,8 +263,6 @@ rootCloseEvent | One of:<br/>'click'<br/>'mousedown' | | Which event when fired
266263
Name | Type | Default | Description
267264
:--- | :--- | :------ | :----------
268265
componentClass | element | div | A custom element for this component.
269-
open | boolean | false | Whether or not the dropdown is visible.
270-
pullRight | boolean | false | Align the menu to the right side of the dropdown toggle.
271266
onClose | function(event) | | A callback fired when the dropdown menu closes.
272267
onSelect | function(eventKey, event) | | A callback fired when a menu item is selected.
273268
rootCloseEvent | One of:<br/>'click'<br/>'mousedown' | | Which event when fired outside the component will cause it to be closed.
@@ -284,7 +279,6 @@ eventKey | any | | Value passed to the `onSelect` handler, useful for identifyin
284279
header | boolean | false | Style the menu item as a header label, useful for describing a group of menu items.
285280
onClick | function(event) | | Callback fired when the menu item is clicked, even if it is disabled.
286281
open | boolean | false | Whether or not the dropdown submenu is visible.
287-
pullRight | boolean | false | Align the menu to the right side of the dropdown toggle.
288282
onClose | function(event) | | A callback fired when the dropdown menu closes.
289283
onSelect | function(eventKey, event) | | A callback fired when a menu item is selected.
290284
rootCloseEvent | One of:<br/>'click'<br/>'mousedown' | | Which event when fired outside the component will cause it to be closed.

examples/DropdownMenuWrapper.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ export default () => (
88
<div className={styles.sectionGroup}>
99
<h3>Dropdown Menu Wrapper</h3>
1010
<Dropdown
11-
open
1211
onToggle={() => {}}
12+
open
1313
>
1414
<Dropdown.Toggle title="Custom range" />
15-
<Dropdown.MenuWrapper style={{ whiteSpace: 'nowrap' }}>
15+
<Dropdown.MenuWrapper
16+
style={{ whiteSpace: 'nowrap' }}
17+
>
1618
<Dropdown.Menu>
1719
<MenuItem eventKey="1d">
1820
Last 24 hours

src/Dropdown.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,11 @@ class Dropdown extends PureComponent {
326326

327327
if (this.isDropdownMenu(child) || this.isDropdownMenuWrapper(child)) {
328328
return this.renderMenu(child, {
329-
open, pullRight, onClose, onSelect, rootCloseEvent
329+
open,
330+
pullRight,
331+
onClose,
332+
onSelect,
333+
rootCloseEvent
330334
});
331335
}
332336

src/DropdownMenu.jsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ class DropdownMenu extends PureComponent {
3030
};
3131

3232
static defaultProps = {
33-
componentClass: 'div',
34-
35-
// Dropdown
36-
open: false,
37-
pullRight: false
33+
componentClass: 'div'
3834
};
3935

4036
isMenuItem = match(MenuItem);
@@ -120,7 +116,7 @@ class DropdownMenu extends PureComponent {
120116
className={cx(className, {
121117
[styles.dropdownMenu]: true,
122118
[styles.selected]: activeMenuItems.length > 0,
123-
[styles.pullRight]: pullRight
119+
[styles.pullRight]: !!pullRight
124120
})}
125121
style={style}
126122
>

src/DropdownMenuWrapper.jsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ class DropdownMenuWrapper extends PureComponent {
3030
};
3131

3232
static defaultProps = {
33-
componentClass: 'div',
34-
35-
// Dropdown
36-
open: false,
37-
pullRight: false
33+
componentClass: 'div'
3834
};
3935

4036
menu = null; // <DropdownMenu ref={c => this.menu = c} />
@@ -91,7 +87,8 @@ class DropdownMenuWrapper extends PureComponent {
9187
<Component
9288
{...props}
9389
className={cx(className, {
94-
[styles.dropdownMenuWrapper]: true
90+
[styles.dropdownMenuWrapper]: true,
91+
[styles.pullRight]: !!pullRight
9592
})}
9693
>
9794
{React.Children.map(children, child => {
@@ -102,7 +99,9 @@ class DropdownMenuWrapper extends PureComponent {
10299
if (this.isDropdownMenu(child)) {
103100
return this.renderMenu(child, {
104101
// Do not pass onClose and rootCloseEvent to the dropdown menu
105-
open, pullRight, onSelect
102+
open,
103+
pullRight,
104+
onSelect
106105
});
107106
}
108107

src/dropdown-menu-wrapper.styl

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
background-color: #fff;
88
border: 1px solid #bbbbbb;
99
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
10+
11+
&.pull-right {
12+
right: 0;
13+
left: auto;
14+
}
1015
}
1116

1217
.dropdown-menu-wrapper > .dropdown-menu {

0 commit comments

Comments
 (0)