Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Make Dropdown trigger/menu detection more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsJonQ committed Oct 6, 2017
1 parent a9e098f commit 587e2ec
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@ class Dropdown extends Component {
className
)

const triggerMarkup = React.cloneElement(children[0], {
const isChildTrigger = children && children[0] && React.isValidElement(children[0])
const isChildMenu = children && children[1] && React.isValidElement(children[1]) && children[1].type === Menu

const triggerMarkup = isChildTrigger ? React.cloneElement(children[0], {
isActive: isOpen,
ref: 'trigger',
onFocus: handleOnTriggerFocus
})
const menuMarkup = isOpen ? React.cloneElement(children[1], {
}) : null

const menuMarkup = isOpen && isChildMenu ? React.cloneElement(children[1], {
direction,
isOpen,
onClose: handleOnMenuClose,
Expand Down

0 comments on commit 587e2ec

Please sign in to comment.