Commit 214c1078 by Ivana Huckova Committed by GitHub

Graphite: Show and hide query editor function popup on click (#26923)

* Update UX, only click on function can open and close popover

* Add ClickOutsideWrapper
parent 826184c9
import React, { Suspense } from 'react';
import { PopoverController, Popover } from '@grafana/ui';
import { PopoverController, Popover, ClickOutsideWrapper } from '@grafana/ui';
import { FunctionDescriptor, FunctionEditorControls, FunctionEditorControlsProps } from './FunctionEditorControls';
interface FunctionEditorProps extends FunctionEditorControlsProps {
......@@ -73,7 +73,7 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd
render() {
return (
<PopoverController content={this.renderContent} placement="top" hideAfter={300}>
<PopoverController content={this.renderContent} placement="top" hideAfter={100}>
{(showPopper, hidePopper, popperProps) => {
return (
<>
......@@ -85,26 +85,30 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd
className="popper__background"
onMouseLeave={() => {
this.setState({ showingDescription: false });
hidePopper();
}}
onMouseEnter={showPopper}
renderArrow={({ arrowProps, placement }) => (
<div className="popper__arrow" data-placement={placement} {...arrowProps} />
)}
/>
)}
<span
ref={this.triggerRef}
onClick={popperProps.show ? hidePopper : showPopper}
onMouseLeave={() => {
hidePopper();
this.setState({ showingDescription: false });
<ClickOutsideWrapper
onClick={() => {
if (popperProps.show) {
hidePopper();
}
}}
style={{ cursor: 'pointer' }}
>
{this.props.func.def.name}
</span>
<span
ref={this.triggerRef}
onClick={popperProps.show ? hidePopper : showPopper}
onMouseLeave={() => {
this.setState({ showingDescription: false });
}}
style={{ cursor: 'pointer' }}
>
{this.props.func.def.name}
</span>
</ClickOutsideWrapper>
</>
);
}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment