mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Fix incompatible ie11 method * Comment about origin of polyfill
This commit is contained in:
parent
824512d49a
commit
2fda59ba2b
1 changed files with 24 additions and 2 deletions
|
@ -58,6 +58,21 @@ const configuration = {
|
|||
tooltipZ: 1100,
|
||||
};
|
||||
|
||||
// Polyfill for browsers (IE11) that don't have element.closest
|
||||
// From: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
|
||||
function closest(s) {
|
||||
let el = this;
|
||||
const matchFn = el.matches ? 'matches' : 'msMatchesSelector';
|
||||
|
||||
do {
|
||||
if (el[matchFn](s)) {
|
||||
return el;
|
||||
}
|
||||
el = el.parentElement || el.parentNode;
|
||||
} while (el !== null && el.nodeType === 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
const componentLayoutState = ({
|
||||
aeroStore,
|
||||
setAeroStore,
|
||||
|
@ -197,8 +212,15 @@ export const InteractivePage = compose(
|
|||
})),
|
||||
withProps((...props) => ({
|
||||
...props,
|
||||
canDragElement: element =>
|
||||
!element.closest('.embeddable') || element.closest('.embPanel__header'),
|
||||
canDragElement: element => {
|
||||
const hasClosest = typeof element.closest === 'function';
|
||||
|
||||
if (hasClosest) {
|
||||
return !element.closest('.embeddable') || element.closest('.embPanel__header');
|
||||
} else {
|
||||
return !closest.call(element, '.embeddable') || closest.call(element, '.embPanel__header');
|
||||
}
|
||||
},
|
||||
})),
|
||||
withHandlers(eventHandlers), // Captures user intent, needs to have reconciled state
|
||||
() => InteractiveComponent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue