diff --git a/src/components/dropdown/Dropdown.js b/src/components/dropdown/Dropdown.js index 102c54bd52..73b36a8b2f 100644 --- a/src/components/dropdown/Dropdown.js +++ b/src/components/dropdown/Dropdown.js @@ -202,10 +202,12 @@ export class Dropdown extends Component { //space case 32: - if (!this.state.overlayVisible) { + if (this.state.overlayVisible) + this.hideOverlay(); + else this.showOverlay(); - event.preventDefault(); - } + + event.preventDefault(); break; //enter @@ -604,19 +606,14 @@ export class Dropdown extends Component { alignPanel() { const container = this.input.parentElement; - if (this.props.appendTo) { - this.overlayRef.current.style.minWidth = DomHandler.getWidth(container) + 'px'; - DomHandler.absolutePosition(this.overlayRef.current, container); - } - else { - DomHandler.relativePosition(this.overlayRef.current, container); - } + this.overlayRef.current.style.minWidth = DomHandler.getOuterWidth(container) + 'px'; + DomHandler.absolutePosition(this.overlayRef.current, container); } scrollInView() { let highlightItem = DomHandler.findSingle(this.overlayRef.current, 'li.p-highlight'); if (highlightItem) { - highlightItem.scrollIntoView({ block: 'end' }); + highlightItem.scrollIntoView({ block: 'nearest', inline: 'start' }); } } diff --git a/src/components/dropdown/DropdownPanel.js b/src/components/dropdown/DropdownPanel.js index 688ebd0c74..5e3c4e65f9 100644 --- a/src/components/dropdown/DropdownPanel.js +++ b/src/components/dropdown/DropdownPanel.js @@ -29,7 +29,7 @@ class DropdownPanelComponent extends Component { return ( + unmountOnExit onEnter={this.props.onEnter} onEntering={this.props.onEntering} onEntered={this.props.onEntered} onExit={this.props.onExit} onExited={this.props.onExited}>
{this.props.filter}
@@ -45,12 +45,7 @@ class DropdownPanelComponent extends Component { render() { let element = this.renderElement(); - if (this.props.appendTo) { - return ReactDOM.createPortal(element, this.props.appendTo); - } - else { - return element; - } + return ReactDOM.createPortal(element, this.props.appendTo || document.body); } }