Skip to content

Commit

Permalink
Fixed #226
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Dec 6, 2017
1 parent 037d91f commit 6d62b24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ export class Dropdown extends Component {
});
}
}

if(selectedItemIndex === -1) {
this.selectItem({
originalEvent: event,
option: this.props.options[0]
});
}
}
}

event.preventDefault();
Expand Down Expand Up @@ -434,6 +435,11 @@ export class Dropdown extends Component {
if(this.props.filter) {
this.alignPanel();
}

if(this.panel.element.offsetParent) {
let highlightItem = DomHandler.findSingle(this.panel.element, 'li.ui-state-highlight');
DomHandler.scrollInView(this.panel.itemsWrapper, highlightItem);
}
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/dropdown/DropdownPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DropdownPanel extends Component {
return (
<div ref={(el) => this.element = el} className={className} style={this.props.panelStyle} onClick={this.props.onClick}>
{this.props.filter}
<div className="ui-dropdown-items-wrapper" style={{ maxHeight: this.props.scrollHeight || 'auto' }}>
<div ref={(el) => this.itemsWrapper = el} className="ui-dropdown-items-wrapper" style={{ maxHeight: this.props.scrollHeight || 'auto' }}>
<ul className="ui-dropdown-items ui-dropdown-list ui-widget-content ui-widget ui-corner-all ui-helper-reset">
{this.props.children}
</ul>
Expand Down

0 comments on commit 6d62b24

Please sign in to comment.