1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import Menu from '@material-ui/core/Menu';
7 import IconButton from '@material-ui/core/IconButton';
8 import { PopoverOrigin } from '@material-ui/core/Popover';
10 interface DropdownMenuProps {
12 icon: React.ReactElement<any>;
15 interface DropdownMenuState {
19 export class DropdownMenu extends React.Component<DropdownMenuProps, DropdownMenuState> {
24 transformOrigin: PopoverOrigin = {
30 const { icon, id, children } = this.props;
31 const { anchorEl } = this.state;
35 aria-owns={anchorEl ? id : undefined}
38 onClick={this.handleOpen}>
44 open={Boolean(anchorEl)}
45 onClose={this.handleClose}
46 onClick={this.handleClose}
47 anchorOrigin={this.transformOrigin}
48 transformOrigin={this.transformOrigin}>
56 this.setState({ anchorEl: undefined });
59 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
60 this.setState({ anchorEl: event.currentTarget });