From: Michal Klobukowski Date: Tue, 18 Dec 2018 09:08:15 +0000 (+0100) Subject: Replace ClickAwayListener with Popover X-Git-Tag: 1.4.0~71^2~16^2~4 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/721322dd1f2af54d1aaa831a96dcf78ed0065085 Replace ClickAwayListener with Popover Feature #14603 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- diff --git a/src/views-components/search-bar/search-bar-view.tsx b/src/views-components/search-bar/search-bar-view.tsx index 51ea3fa1..8aa8ffa7 100644 --- a/src/views-components/search-bar/search-bar-view.tsx +++ b/src/views-components/search-bar/search-bar-view.tsx @@ -11,7 +11,7 @@ import { WithStyles, Tooltip, InputAdornment, Input, - ClickAwayListener + Popover } from '@material-ui/core'; import SearchIcon from '@material-ui/icons/Search'; import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown'; @@ -144,47 +144,74 @@ const handleDropdownClick = (e: React.MouseEvent, props: SearchBarViewProps) => }; export const SearchBarView = withStyles(styles)( - (props : SearchBarViewProps) => { - const { classes, isPopoverOpen } = props; - return ( - - -
- handleInputClick(e, props)} - onKeyDown={e => handleKeyDown(e, props)} - startAdornment={ - - - - - - - - } - endAdornment={ - - - handleDropdownClick(e, props)}> - - - - - } /> -
-
- {isPopoverOpen && getView({...props})} + class SearchBarView extends React.Component { + + viewAnchorRef = React.createRef(); + + render() { + const { children, ...props } = this.props; + const { classes, isPopoverOpen } = props; + return ( + +
+
+ handleInputClick(e, props)} + onKeyDown={e => handleKeyDown(e, props)} + startAdornment={ + + + + + + + + } + endAdornment={ + + + handleDropdownClick(e, props)}> + + + + + } /> +
+ + {getView({ ...props })} +
- - ); + ); + } + + getViewWidth() { + const { current } = this.viewAnchorRef; + return current ? current.offsetWidth : 0; + } } + ); const getView = (props: SearchBarViewProps) => {