Skip to content

Commit

Permalink
fix(point): Fix pointFucusOnly check error
Browse files Browse the repository at this point in the history
Fix side effect caused by naver#3407.
Add prevention on call of .isPointFocusOnly()

Fix naver#3456
  • Loading branch information
netil authored Oct 12, 2023
1 parent 4cdc831 commit f9b65ac
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ChartInternal/interactions/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default {
$$.cache.add(KEY.setOverOut, last);
} else {
if (isOver) {
$$.isPointFocusOnly() && hasRadar ?
hasRadar && $$.isPointFocusOnly() ?
$$.showCircleFocus($$.getAllValuesOnIndex(d, true)) :
$$.setExpand(d, null, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ChartInternal/internals/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default {
let toggledShape;

if (!config.data_selection_multiple) {
const focusOnly = $$.isPointFocusOnly();
const focusOnly = $$.isPointFocusOnly?.();
let selector = `.${focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes}`;

if (config.data_selection_grouped) {
Expand Down
4 changes: 2 additions & 2 deletions src/ChartInternal/shape/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
let opacity = config.point_opacity;

if (isUndefined(opacity)) {
opacity = config.point_show && !this.isPointFocusOnly() ? null : "0";
opacity = config.point_show && !this.isPointFocusOnly?.() ? null : "0";

opacity = isValue(this.getBaseValue(d)) ?
(this.isBubbleType(d) || this.isScatterType(d) ?
Expand Down Expand Up @@ -210,7 +210,7 @@ export default {
const {state: {hasRadar, resizing, toggling, transiting}, $el} = $$;
let {circle} = $el;

if (transiting === false && $$.isPointFocusOnly() && circle) {
if (transiting === false && circle && $$.isPointFocusOnly()) {
const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
const withTransition = toggling || isUndefined(d);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/sparkline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default class Sparkline extends Plugin {

$$.state.event = e;

if ($$.isPointFocusOnly() && d) {
if ($$.isPointFocusOnly?.() && d) {
$$.showCircleFocus?.([d]);
}

Expand Down
15 changes: 15 additions & 0 deletions test/esm/bar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,20 @@ describe("ESM bar", function() {

proto.showCircleFocus = fn;
});

it("shoudn't throw error on tooltip show", () => {
const proto = Object.getPrototypeOf(chart.internal);
const {isPointFocusOnly} = proto;

// delete temporarly for test
delete proto.isPointFocusOnly;

expect(
chart.tooltip.show({x: 2})
).to.not.throw;

// restore
proto.isPointFocusOnly = isPointFocusOnly;
});
});
});

0 comments on commit f9b65ac

Please sign in to comment.