Skip to content

Commit

Permalink
fix(staticMethods): fixing IE event bug (ReactTooltip#569)
Browse files Browse the repository at this point in the history
fixing currentTarget for static method global show (in IE)
  • Loading branch information
Jarch09 authored Apr 2, 2020
1 parent 2ed7f6a commit 9acc591
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/decorators/staticMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CONSTANT from "../constant";
const dispatchGlobalEvent = (eventName, opts) => {
// Compatible with IE
// @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
// @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
let event;

if (typeof window.CustomEvent === "function") {
Expand Down Expand Up @@ -52,10 +53,11 @@ export default function(target) {

target.prototype.globalShow = function(event) {
if (this.mount) {
const hasTarget =
(event && event.detail && event.detail.target && true) || false;
// Create a fake event, specific show will limit the type to `solid`
// only `float` type cares e.clientX e.clientY
const e = { currentTarget: event.detail.target };
this.showTooltip(e, true);
this.showTooltip({ currentTarget: hasTarget && event.detail.target }, true);
}
};

Expand Down

0 comments on commit 9acc591

Please sign in to comment.