Skip to content

Commit

Permalink
[components] Add escape handler to menu button
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent b373c77 commit e78f7a2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@sanity/components/src/menuButton/menuButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Button from 'part:@sanity/components/buttons/default'
import {ClickOutside} from 'part:@sanity/components/click-outside'
import {Popover} from 'part:@sanity/components/popover'
import Escapable from 'part:@sanity/components/utilities/escapable'
import React, {useCallback} from 'react'
import {ButtonProps} from '../buttons'
import {Placement} from '../types'
Expand Down Expand Up @@ -45,6 +46,8 @@ export function MenuButton(props: MenuButtonProps & React.HTMLProps<HTMLDivEleme
</Button>
</div>
</Popover>

{open && <Escapable onEscape={handleClose} />}
</div>
)}
</ClickOutside>
Expand Down

0 comments on commit e78f7a2

Please sign in to comment.