Skip to content

Commit

Permalink
fix(core): point selections when tooltip is disabled
Browse files Browse the repository at this point in the history
uniqueId was missing when tooltip was disabled
  • Loading branch information
tuner committed Mar 7, 2024
1 parent ecf6ca0 commit aad6b33
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/marks/mark.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,13 +951,12 @@ export default class Mark {

/**
* Returns true if this mark instance participates in picking.
*
* TODO: Check if tooltip is enabled,
* TODO: Check if selection (when it's implemented) is enabled
*/
isPickingParticipant() {
// TODO: Should check encoding instead
if (this.properties.tooltip === null) {
if (
this.properties.tooltip === null &&
!this.unitView.paramMediator.hasPointSelections()
) {
// Disabled
return false;
}
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/view/paramMediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,29 @@ export default class ParamMediator {
const fn = this.createExpression(expr);
return fn();
}

/**
* Returns true if this ParamMediator has any parameters that are point selections.
* Point selections necessitate the use of uniqueIds in the data.
*
* @returns {boolean}
*/
hasPointSelections() {
for (const param of this.#paramConfigs.values()) {
if (isSelectionParameter(param)) {
const select = param.select;
if (isString(select)) {
if (select == "point") {
return true;
}
} else if (select.type == "point") {
return true;
}
}
}

return false;
}
}

/**
Expand Down
20 changes: 20 additions & 0 deletions packages/core/src/view/paramMediator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,23 @@ test("activateExprRefProps", async () => {
c: 2,
});
});

describe("hasPointSelections()", () => {
test("false if there are no point selections", () => {
const pm = new ParamMediator();
pm.registerParam({ name: "foo", value: 42 });
expect(pm.hasPointSelections()).toBe(false);
});

test("true if there are point selections (1/2)", () => {
const pm = new ParamMediator();
pm.registerParam({ name: "foo", select: "point" });
expect(pm.hasPointSelections()).toBe(true);
});

test("true if there are point selections (2/2)", () => {
const pm = new ParamMediator();
pm.registerParam({ name: "foo", select: { type: "point" } });
expect(pm.hasPointSelections()).toBe(true);
});
});

0 comments on commit aad6b33

Please sign in to comment.