Skip to content

Commit

Permalink
refactor(tooltip): Remove optional chainigs (#3411)
Browse files Browse the repository at this point in the history
Remove optional chaining as a possible prevention from the fix of #3407
Can be removed, as of conditional from event interaction will prevent it.
  • Loading branch information
netil committed Sep 8, 2023
1 parent 990fcf7 commit ca96f85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ChartInternal/internals/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default {
const $$ = this;
const {config, scale, state, $el: {eventRect, tooltip}} = $$;
const {bindto} = config.tooltip_contents;
const datum = tooltip?.datum?.();
const datum = tooltip?.datum();

if (!bindto && datum) {
const [x, y] = getPointer(state.event, eventTarget ?? eventRect?.node()); // get mouse event position
Expand Down Expand Up @@ -373,7 +373,7 @@ export default {
return;
}

let datum = tooltip?.datum?.();
let datum = tooltip.datum();
const dataStr = JSON.stringify(selectedData);

if (!datum || datum.current !== dataStr) {
Expand Down Expand Up @@ -441,7 +441,7 @@ export default {
const {api, config, $el: {tooltip}} = $$;

if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
const selectedData = JSON.parse(tooltip?.datum?.().current ?? {});
const selectedData = JSON.parse(tooltip.datum().current ?? {});

callFn(config.tooltip_onhide, api, selectedData);

Expand Down

0 comments on commit ca96f85

Please sign in to comment.