mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fix: IE11 SVG elements have neither classList nor parentElement... (#26035)
This commit is contained in:
parent
c8647f109b
commit
b3ef0c4eaf
1 changed files with 6 additions and 5 deletions
|
@ -6,10 +6,11 @@
|
|||
|
||||
import { withHandlers } from 'recompose';
|
||||
|
||||
const ancestorElement = (element, className) => {
|
||||
const ancestorElement = element => {
|
||||
if (!element) return element;
|
||||
do if (element.classList.contains(className)) return element;
|
||||
while ((element = element.parentElement));
|
||||
// IE11 has no classList on SVG elements, but we're not interested in SVG elements
|
||||
do if (element.classList && element.classList.contains('canvasPage')) return element;
|
||||
while ((element = element.parentElement || element.parentNode)); // no IE11 SVG parentElement
|
||||
};
|
||||
|
||||
const localMousePosition = (box, clientX, clientY) => {
|
||||
|
@ -27,7 +28,7 @@ const resetHandler = () => {
|
|||
const setupHandler = (commit, target) => {
|
||||
// Ancestor has to be identified on setup, rather than 1st interaction, otherwise events may be triggered on
|
||||
// DOM elements that had been removed: kibana-canvas github issue #1093
|
||||
const canvasPage = ancestorElement(target, 'canvasPage');
|
||||
const canvasPage = ancestorElement(target);
|
||||
if (!canvasPage) return;
|
||||
const canvasOrigin = canvasPage.getBoundingClientRect();
|
||||
window.onmousemove = ({ clientX, clientY, altKey, metaKey, shiftKey }) => {
|
||||
|
@ -63,7 +64,7 @@ const handleMouseDown = (commit, e, isEditable) => {
|
|||
resetHandler();
|
||||
return; // left-click and edit mode only
|
||||
}
|
||||
const ancestor = ancestorElement(target, 'canvasPage');
|
||||
const ancestor = ancestorElement(target);
|
||||
if (!ancestor) return;
|
||||
const { x, y } = localMousePosition(ancestor, clientX, clientY);
|
||||
setupHandler(commit, ancestor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue