Skip to content

Commit

Permalink
fix(DropdownMenu): Fixes dropdown menu when using items as children. (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 authored and tlabaj committed Jan 18, 2019
1 parent e4b2653 commit 279a595
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,31 @@ class DropdownMenu extends React.Component {

render() {
const { className, isOpen, position, children, component: Component, openedOnEnter, ...props } = this.props;
let menu = null;
if (Component === 'div') {
menu = (
<DropdownContext.Consumer>
{onSelect => (
<Component
{...props}
className={css(
styles.dropdownMenu,
position === DropdownPosition.right && styles.modifiers.alignRight,
className
)}
hidden={!isOpen}
onClick={event => onSelect && onSelect(event)}
>
{this.extendCustomChildren()}
</Component>
)}
</DropdownContext.Consumer>
);
} else if (Component === 'ul') {
menu = (
<DropdownArrowContext.Provider
value={{
keyHandler: this.keyHandler,
sendRef: this.sendRef
}}
>

return (
<DropdownArrowContext.Provider
value={{
keyHandler: this.keyHandler,
sendRef: this.sendRef
}}
>
{Component === 'div' ? (
<DropdownContext.Consumer>
{onSelect => (
<ul
className={css(
styles.dropdownMenu,
position === DropdownPosition.right && styles.modifiers.alignRight,
className
)}
hidden={!isOpen}
onClick={event => onSelect && onSelect(event)}
>
<Component {...props}>{this.extendCustomChildren()}</Component>
</ul>
)}
</DropdownContext.Consumer>
) : (
<Component
{...props}
className={css(
Expand All @@ -158,10 +155,9 @@ class DropdownMenu extends React.Component {
>
{this.extendChildren()}
</Component>
</DropdownArrowContext.Provider>
);
}
return menu;
)}
</DropdownArrowContext.Provider>
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,24 @@ exports[`KebabToggle basic 1`] = `
isOpen={true}
position="left"
>
<div
aria-labelledby="Dropdown Toggle"
<ul
className="pf-c-dropdown__menu"
hidden={false}
onClick={[Function]}
>
<div
className="pf-c-dropdown__menu-item"
key=".0"
onKeyDown={[Function]}
tabIndex={-1}
aria-labelledby="Dropdown Toggle"
>
BASIC
<div
className="pf-c-dropdown__menu-item"
key=".0"
onKeyDown={[Function]}
tabIndex={-1}
>
BASIC
</div>
</div>
</div>
</ul>
</DropdownMenu>
</div>
</Dropdown>
Expand Down Expand Up @@ -1966,21 +1969,24 @@ exports[`dropdown basic 1`] = `
isOpen={true}
position="left"
>
<div
aria-labelledby="Dropdown Toggle"
<ul
className="pf-c-dropdown__menu"
hidden={false}
onClick={[Function]}
>
<div
className="pf-c-dropdown__menu-item"
key=".0"
onKeyDown={[Function]}
tabIndex={-1}
aria-labelledby="Dropdown Toggle"
>
BASIC
<div
className="pf-c-dropdown__menu-item"
key=".0"
onKeyDown={[Function]}
tabIndex={-1}
>
BASIC
</div>
</div>
</div>
</ul>
</DropdownMenu>
</div>
</Dropdown>
Expand Down

0 comments on commit 279a595

Please sign in to comment.