fix(ui): pass unique class to alert action button, so clicking it doesn't trigger click outside handler

This commit is contained in:
Łukasz Mierzwa
2018-09-08 23:35:21 +01:00
parent 7da2c66200
commit 26abcc632b
2 changed files with 9 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ import PropTypes from "prop-types";
import { action, observable } from "mobx";
import { observer } from "mobx-react";
import hash from "object-hash";
import { Manager, Reference, Popper } from "react-popper";
import onClickOutside from "react-onclickoutside";
@@ -97,12 +99,16 @@ const AlertMenu = observer(
render() {
const { group, alert, silenceFormStore } = this.props;
const uniqueClass = `components-grid-alert-${group.id}-${hash(
alert.labels
)}`;
return (
<Manager>
<Reference>
{({ ref }) => (
<span
className="components-label-with-hover text-nowrap text-truncate px-1 mr-1 badge badge-secondary cursor-pointer"
className={`components-label-with-hover text-nowrap text-truncate px-1 mr-1 badge badge-secondary cursor-pointer ${uniqueClass}`}
ref={ref}
onClick={this.collapse.toggle}
data-toggle="dropdown"
@@ -134,6 +140,7 @@ const AlertMenu = observer(
silenceFormStore={silenceFormStore}
afterClick={this.collapse.hide}
handleClickOutside={this.collapse.hide}
outsideClickIgnoreClass={uniqueClass}
/>
)}
</Popper>

View File

@@ -42,7 +42,7 @@ exports[`<Alert /> matches snapshot with showAlertmanagers=false showReceiver=fa
hidden
</div>
</div>
<span class=\\"components-label-with-hover text-nowrap text-truncate px-1 mr-1 badge badge-secondary cursor-pointer\\"
<span class=\\"components-label-with-hover text-nowrap text-truncate px-1 mr-1 badge badge-secondary cursor-pointer components-grid-alert-undefined-0988cb349635341c67d91bfe3454d2b3178c443c\\"
data-toggle=\\"dropdown\\"
>
<svg aria-hidden=\\"true\\"