Skip to content
Snippets Groups Projects
Unverified Commit dfd54ce9 authored by Tom Robinson's avatar Tom Robinson
Browse files

Fix brush issue when cancelling

parent 3aee0ec7
No related branches found
No related tags found
No related merge requests found
......@@ -208,3 +208,18 @@ export function constrainToScreen(element, direction, padding) {
}
return false;
}
export function moveToBack(element) {
if (element && element.parentNode) {
element.parentNode.insertBefore(
element,
element.parentNode.firstChild
);
}
}
export function moveToFront(element) {
if (element && element.parentNode) {
element.parentNode.appendChild(element);
}
}
import { KEYCODE_ESCAPE } from "metabase/lib/keyboard";
import { moveToBack, moveToFront } from "metabase/lib/dom";
export function initBrush(parent, child, onBrushChange, onBrushEnd) {
if (!child.brushOn) {
......@@ -20,6 +21,8 @@ export function initBrush(parent, child, onBrushChange, onBrushEnd) {
// start
parent.brush().on("brushstart.custom", () => {
// reset "range"
range = null;
// reset "cancelled" flag
cancelled = false;
// add "dragging" class to chart
......@@ -61,6 +64,7 @@ export function initBrush(parent, child, onBrushChange, onBrushEnd) {
// if not cancelled, emit the onBrushEnd event with the last filter range
onBrushEnd(cancelled ? null : range);
range = null;
});
// cancel
......@@ -80,17 +84,3 @@ export function initBrush(parent, child, onBrushChange, onBrushEnd) {
chart.selectAll(".brush .resize").remove();
});
}
function moveToBack(element) {
if (element && element.parentNode) {
element.parentNode.insertBefore(
element,
element.parentNode.firstChild
);
}
}
function moveToFront(element) {
if (element && element.parentNode) {
element.parentNode.appendChild(element);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment