Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit b939d30

Browse files
fix(Dropdown): rendering up
1 parent 4858171 commit b939d30

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

src/Dropdown/Dropdown.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class Dropdown extends Util.mixin(BindMixin) {
2020
"handleExternalClick",
2121
"handleKeyDown",
2222
"handleMenuRender",
23-
"handleWrapperBlur",
24-
"setDropdownMenuRef",
25-
"setDropdownWrapperRef"
23+
"handleWrapperBlur"
2624
];
2725
}
2826

@@ -38,6 +36,8 @@ class Dropdown extends Util.mixin(BindMixin) {
3836
renderHidden: false,
3937
selectedID: null
4038
};
39+
this.dropdownMenuRef = React.createRef();
40+
this.dropdownWrapperRef = React.createRef();
4141
}
4242

4343
componentWillMount() {
@@ -161,7 +161,7 @@ class Dropdown extends Util.mixin(BindMixin) {
161161
let menuDirection = this.state.menuDirection;
162162
const menuPositionStyle = {};
163163
const spaceAroundDropdownButton = DOMUtil.getNodeClearance(
164-
this.dropdownWrapperRef
164+
this.dropdownWrapperRef.current
165165
);
166166
const dropdownChildHeight =
167167
this.dropdownMenuRef && this.dropdownMenuRef.current
@@ -174,7 +174,6 @@ class Dropdown extends Util.mixin(BindMixin) {
174174
const isMenuShorterThanTop = !isMenuTallerThanTop;
175175
const isTopTallerThanBottom =
176176
spaceAroundDropdownButton.top > spaceAroundDropdownButton.bottom;
177-
178177
// If the menu height is larger than the space available on the bottom and
179178
// less than the space available on top, then render it up. If the height
180179
// of the menu exceeds the space below and above, but there is more space
@@ -317,14 +316,6 @@ class Dropdown extends Util.mixin(BindMixin) {
317316
);
318317
}
319318

320-
setDropdownMenuRef(element) {
321-
this.dropdownMenuRef = element;
322-
}
323-
324-
setDropdownWrapperRef(element) {
325-
this.dropdownWrapperRef = element;
326-
}
327-
328319
render() {
329320
// Set a key based on the menu height so that React knows to keep the
330321
// the DOM element around while we are measuring it.
@@ -386,7 +377,7 @@ class Dropdown extends Util.mixin(BindMixin) {
386377
key="dropdown-menu-key"
387378
className={dropdownMenuClassSet}
388379
role="menu"
389-
ref={this.setDropdownMenuRef}
380+
ref={this.dropdownMenuRef}
390381
style={state.menuPositionStyle}
391382
>
392383
<div className={props.dropdownMenuListClassName}>
@@ -396,18 +387,16 @@ class Dropdown extends Util.mixin(BindMixin) {
396387
);
397388
}
398389

399-
// if (state.renderHidden) {
400-
// dropdownMenu = (
401-
// <div key="concealer" className="dropdown-menu-concealer">
402-
// {dropdownMenu}
403-
// </div>
404-
// );
405-
// }
406-
407-
if (props.transition) {
390+
if (state.renderHidden) {
391+
dropdownMenu = (
392+
<div key="concealer" className="dropdown-menu-concealer">
393+
{dropdownMenu}
394+
</div>
395+
);
396+
} else if (props.transition) {
408397
dropdownMenu = (
409398
<CSSTransition
410-
in={state.isOpen && !state.renderHidden}
399+
in={state.isOpen}
411400
classNames={transitionName}
412401
timeout={{
413402
enter: props.transitionEnterTimeout,
@@ -424,7 +413,7 @@ class Dropdown extends Util.mixin(BindMixin) {
424413
className={wrapperClassSet}
425414
tabIndex="1"
426415
onBlur={this.handleWrapperBlur}
427-
ref={this.setDropdownWrapperRef}
416+
ref={this.dropdownWrapperRef}
428417
>
429418
{React.cloneElement(trigger, {
430419
selectedItem: this.getSelectedItem(this.getSelectedID(), items),

0 commit comments

Comments
 (0)