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 React, { Suspense } from 'react';
import { PopoverController, Popover } from '@grafana/ui'; import { PopoverController, Popover, ClickOutsideWrapper } from '@grafana/ui';
import { FunctionDescriptor, FunctionEditorControls, FunctionEditorControlsProps } from './FunctionEditorControls'; import { FunctionDescriptor, FunctionEditorControls, FunctionEditorControlsProps } from './FunctionEditorControls';
interface FunctionEditorProps extends FunctionEditorControlsProps { interface FunctionEditorProps extends FunctionEditorControlsProps {
...@@ -73,7 +73,7 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd ...@@ -73,7 +73,7 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd
render() { render() {
return ( return (
<PopoverController content={this.renderContent} placement="top" hideAfter={300}> <PopoverController content={this.renderContent} placement="top" hideAfter={100}>
{(showPopper, hidePopper, popperProps) => { {(showPopper, hidePopper, popperProps) => {
return ( return (
<> <>
...@@ -85,26 +85,30 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd ...@@ -85,26 +85,30 @@ class FunctionEditor extends React.PureComponent<FunctionEditorProps, FunctionEd
className="popper__background" className="popper__background"
onMouseLeave={() => { onMouseLeave={() => {
this.setState({ showingDescription: false }); this.setState({ showingDescription: false });
hidePopper();
}} }}
onMouseEnter={showPopper}
renderArrow={({ arrowProps, placement }) => ( renderArrow={({ arrowProps, placement }) => (
<div className="popper__arrow" data-placement={placement} {...arrowProps} /> <div className="popper__arrow" data-placement={placement} {...arrowProps} />
)} )}
/> />
)} )}
<ClickOutsideWrapper
<span onClick={() => {
ref={this.triggerRef} if (popperProps.show) {
onClick={popperProps.show ? hidePopper : showPopper} hidePopper();
onMouseLeave={() => { }
hidePopper();
this.setState({ showingDescription: false });
}} }}
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