Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix(vega): use ctrl for chart pan/zoom on non-mac platforms (#3812) (#10496)

Nikhilb4181abaf6bd
diff --git a/frontend/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap b/frontend/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap
index 28fbcb8fab..1e86a22d2c 100644
--- a/frontend/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap
+++ b/frontend/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap
@@ -44,14 +44,14 @@ exports[`makeSelectable > should add bin_coloring param for 2D binned histogram
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
{
"name": "bin_coloring",
"select": {
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -59,10 +59,10 @@ exports[`makeSelectable > should add bin_coloring param for 2D binned histogram
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -107,14 +107,14 @@ exports[`makeSelectable > should add bin_coloring param for binned charts 1`] =
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
{
"name": "bin_coloring",
"select": {
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -122,10 +122,10 @@ exports[`makeSelectable > should add bin_coloring param for binned charts 1`] =
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -172,14 +172,14 @@ exports[`makeSelectable > should add bin_coloring param for layered binned chart
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
{
"name": "bin_coloring_0",
"select": {
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -187,10 +187,10 @@ exports[`makeSelectable > should add bin_coloring param for layered binned chart
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -235,7 +235,7 @@ exports[`makeSelectable > should add bin_coloring param for layered binned chart
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -252,8 +252,8 @@ exports[`makeSelectable > should add bin_coloring param for layered binned chart
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -326,7 +326,7 @@ exports[`makeSelectable > should add legend selection to composite charts (issue
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -343,8 +343,8 @@ exports[`makeSelectable > should add legend selection to composite charts (issue
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -352,10 +352,10 @@ exports[`makeSelectable > should add legend selection to composite charts (issue
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -406,7 +406,7 @@ exports[`makeSelectable > should add legend selection to composite charts (issue
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -423,8 +423,8 @@ exports[`makeSelectable > should add legend selection to composite charts (issue
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -481,7 +481,7 @@ exports[`makeSelectable > should add legend selection to hconcat specs 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -498,8 +498,8 @@ exports[`makeSelectable > should add legend selection to hconcat specs 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -558,10 +558,10 @@ exports[`makeSelectable > should add legend selection to hconcat specs 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -585,10 +585,10 @@ exports[`makeSelectable > should add legend selection to nested vconcat(hconcat(
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -729,10 +729,10 @@ exports[`makeSelectable > should add legend selection to vconcat specs 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -781,7 +781,7 @@ exports[`makeSelectable > should add legend selection to vconcat specs 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -798,8 +798,8 @@ exports[`makeSelectable > should add legend selection to vconcat specs 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -848,7 +848,7 @@ exports[`makeSelectable > should add legend selection to vconcat specs 1`] = `
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -864,8 +864,8 @@ exports[`makeSelectable > should add legend selection to vconcat specs 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -948,7 +948,7 @@ exports[`makeSelectable > should collect legend fields from multiple layers with
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -965,8 +965,8 @@ exports[`makeSelectable > should collect legend fields from multiple layers with
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -974,10 +974,10 @@ exports[`makeSelectable > should collect legend fields from multiple layers with
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1026,7 +1026,7 @@ exports[`makeSelectable > should collect legend fields from multiple layers with
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1043,8 +1043,8 @@ exports[`makeSelectable > should collect legend fields from multiple layers with
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1102,7 +1102,7 @@ exports[`makeSelectable > should handle concat with only one subspec 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1119,8 +1119,8 @@ exports[`makeSelectable > should handle concat with only one subspec 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1128,10 +1128,10 @@ exports[`makeSelectable > should handle concat with only one subspec 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1191,7 +1191,7 @@ exports[`makeSelectable > should hoist only common legend params when chart sele
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1208,8 +1208,8 @@ exports[`makeSelectable > should hoist only common legend params when chart sele
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1258,7 +1258,7 @@ exports[`makeSelectable > should hoist only common legend params when chart sele
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1274,8 +1274,8 @@ exports[`makeSelectable > should hoist only common legend params when chart sele
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1297,10 +1297,10 @@ exports[`makeSelectable > should hoist only common legend params when chart sele
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1465,7 +1465,7 @@ exports[`makeSelectable > should hoist params to top level in hconcat(vconcat(..
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1482,8 +1482,8 @@ exports[`makeSelectable > should hoist params to top level in hconcat(vconcat(..
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1491,10 +1491,10 @@ exports[`makeSelectable > should hoist params to top level in hconcat(vconcat(..
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1520,10 +1520,10 @@ exports[`makeSelectable > should not add bin_coloring when chartSelection is fal
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1581,10 +1581,10 @@ exports[`makeSelectable > should not duplicate legend params when multiple layer
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1634,7 +1634,7 @@ exports[`makeSelectable > should not duplicate legend params when multiple layer
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1651,8 +1651,8 @@ exports[`makeSelectable > should not duplicate legend params when multiple layer
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1702,7 +1702,7 @@ exports[`makeSelectable > should not hoist params when specs have different enco
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1719,8 +1719,8 @@ exports[`makeSelectable > should not hoist params when specs have different enco
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1772,7 +1772,7 @@ exports[`makeSelectable > should not hoist params when specs have different enco
"encodings": [
"color",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1784,10 +1784,10 @@ exports[`makeSelectable > should not hoist params when specs have different enco
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -1840,7 +1840,7 @@ exports[`makeSelectable > should not hoist params when specs have different sele
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1856,8 +1856,8 @@ exports[`makeSelectable > should not hoist params when specs have different sele
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -1906,7 +1906,7 @@ exports[`makeSelectable > should not hoist params when specs have different sele
"encodings": [
"color",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -1928,10 +1928,10 @@ exports[`makeSelectable > should not hoist params when specs have different sele
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2046,7 +2046,7 @@ exports[`makeSelectable > should only hoist common params with same select.type
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2063,8 +2063,8 @@ exports[`makeSelectable > should only hoist common params with same select.type
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2072,10 +2072,10 @@ exports[`makeSelectable > should only hoist common params with same select.type
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2122,14 +2122,14 @@ exports[`makeSelectable > should prefer point selection for binned charts even w
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
{
"name": "bin_coloring",
"select": {
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2137,10 +2137,10 @@ exports[`makeSelectable > should prefer point selection for binned charts even w
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2221,7 +2221,7 @@ exports[`makeSelectable > should return correctly if existing legend selection 1
"encodings": [
"color",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2229,10 +2229,10 @@ exports[`makeSelectable > should return correctly if existing legend selection 1
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2272,7 +2272,7 @@ exports[`makeSelectable > should return correctly if mark is a string 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2289,8 +2289,8 @@ exports[`makeSelectable > should return correctly if mark is a string 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2298,10 +2298,10 @@ exports[`makeSelectable > should return correctly if mark is a string 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2341,7 +2341,7 @@ exports[`makeSelectable > should return correctly if mark is not string 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2358,8 +2358,8 @@ exports[`makeSelectable > should return correctly if mark is not string 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2367,10 +2367,10 @@ exports[`makeSelectable > should return correctly if mark is not string 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2443,7 +2443,7 @@ exports[`makeSelectable > should return correctly if overlapping encodings 1`] =
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2460,8 +2460,8 @@ exports[`makeSelectable > should return correctly if overlapping encodings 1`] =
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2469,10 +2469,10 @@ exports[`makeSelectable > should return correctly if overlapping encodings 1`] =
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2546,7 +2546,7 @@ exports[`makeSelectable > should return correctly with multiple encodings 1`] =
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2563,8 +2563,8 @@ exports[`makeSelectable > should return correctly with multiple encodings 1`] =
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2572,10 +2572,10 @@ exports[`makeSelectable > should return correctly with multiple encodings 1`] =
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2615,7 +2615,7 @@ exports[`makeSelectable > should return the same spec for not-defined and true 1
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2632,8 +2632,8 @@ exports[`makeSelectable > should return the same spec for not-defined and true 1
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2641,10 +2641,10 @@ exports[`makeSelectable > should return the same spec for not-defined and true 1
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2702,7 +2702,7 @@ exports[`makeSelectable > should return the same spec if mark is not in spec 1`]
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2719,8 +2719,8 @@ exports[`makeSelectable > should return the same spec if mark is not in spec 1`]
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2728,10 +2728,10 @@ exports[`makeSelectable > should return the same spec if mark is not in spec 1`]
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2797,7 +2797,7 @@ exports[`makeSelectable > should skip field selection if empty or false 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2814,8 +2814,8 @@ exports[`makeSelectable > should skip field selection if empty or false 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2823,10 +2823,10 @@ exports[`makeSelectable > should skip field selection if empty or false 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -2931,7 +2931,7 @@ exports[`makeSelectable > should work for layered charts, with existing legend s
"encodings": [
"x",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -2947,8 +2947,8 @@ exports[`makeSelectable > should work for layered charts, with existing legend s
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -2956,10 +2956,10 @@ exports[`makeSelectable > should work for layered charts, with existing legend s
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -3006,7 +3006,7 @@ exports[`makeSelectable > should work for layered charts, with existing legend s
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -3023,8 +3023,8 @@ exports[`makeSelectable > should work for layered charts, with existing legend s
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -3106,10 +3106,10 @@ exports[`makeSelectable > should work for layered charts, with existing selectio
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -3202,10 +3202,10 @@ exports[`makeSelectable > should work for multi-layered charts 1`] = `
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -3248,7 +3248,7 @@ exports[`makeSelectable > should work for multi-layered charts 1`] = `
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -3265,8 +3265,8 @@ exports[`makeSelectable > should work for multi-layered charts 1`] = `
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -3335,7 +3335,7 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"encodings": [
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -3351,8 +3351,8 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -3360,10 +3360,10 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"bind": "scales",
"name": "pan_zoom",
"select": {
- "on": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- "translate": "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
+ "on": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
+ "translate": "[mousedown[event.ctrlKey], window:mouseup] > window:mousemove!",
"type": "interval",
- "zoom": "wheel![event.metaKey]",
+ "zoom": "wheel![event.ctrlKey]",
},
},
],
@@ -3417,7 +3417,7 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -3434,8 +3434,8 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
@@ -3490,7 +3490,7 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"x",
"y",
],
- "on": "click[!event.metaKey]",
+ "on": "click[!event.ctrlKey]",
"type": "point",
},
},
@@ -3507,8 +3507,8 @@ exports[`makeSelectable > should work for multi-layered charts with different se
"stroke": "#669EFF",
"strokeOpacity": 0.4,
},
- "on": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- "translate": "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ "on": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
+ "translate": "[mousedown[!event.ctrlKey], mouseup] > mousemove[!event.ctrlKey]",
"type": "interval",
},
},
diff --git a/frontend/src/plugins/impl/vega/__tests__/make-selectable.test.ts b/frontend/src/plugins/impl/vega/__tests__/make-selectable.test.ts
index fdb62d3967..6422dc9afe 100644
--- a/frontend/src/plugins/impl/vega/__tests__/make-selectable.test.ts
+++ b/frontend/src/plugins/impl/vega/__tests__/make-selectable.test.ts
@@ -2,12 +2,24 @@
// @ts-expect-error - vega-parser is not typed
import { parse } from "vega-parser";
-import { describe, expect, it } from "vitest";
+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import { invariant } from "@/utils/invariant";
import { makeSelectable } from "../make-selectable";
-import { getSelectionParamNames } from "../params";
+import { getPanZoomModifier, getSelectionParamNames } from "../params";
import type { VegaLiteSpec } from "../types";
+// Pin the platform so the pan/zoom modifier (and therefore the snapshots
+// below) is deterministic regardless of the host running the tests. We use a
+// non-Mac platform, which resolves the modifier to `ctrlKey` — this matches
+// the Linux/Windows environment from issue #3812.
+beforeAll(() => {
+ vi.spyOn(window.navigator, "platform", "get").mockReturnValue("Linux x86_64");
+});
+
+afterAll(() => {
+ vi.restoreAllMocks();
+});
+
describe("makeSelectable", () => {
it("should return correctly if mark is not string", () => {
const spec = {
@@ -1268,3 +1280,67 @@ describe("makeSelectable", () => {
expect(getSelectionParamNames(newSpec)).toEqual(["my_selection"]);
});
});
+
+describe("pan/zoom modifier key (issue #3812)", () => {
+ afterAll(() => {
+ vi.restoreAllMocks();
+ });
+
+ function mockPlatform(platform: string) {
+ // jsdom's navigator has no `userAgentData`, so the detection helper falls
+ // back to `navigator.platform`, which is what we override here.
+ vi.spyOn(window.navigator, "platform", "get").mockReturnValue(platform);
+ }
+
+ it("uses metaKey (Command) on macOS", () => {
+ mockPlatform("MacIntel");
+ expect(getPanZoomModifier()).toBe("metaKey");
+
+ const spec = { mark: "point" } as VegaLiteSpec;
+ const newSpec = makeSelectable(spec, {});
+ const panZoom = newSpec.params?.find((p) => p.name === "pan_zoom");
+ invariant(panZoom && "select" in panZoom, "expected pan_zoom param");
+ const select = panZoom.select as { on: string; zoom: string };
+ expect(select.on).toContain("event.metaKey");
+ expect(select.on).not.toContain("event.ctrlKey");
+ expect(select.zoom).toBe("wheel![event.metaKey]");
+ });
+
+ it.each(["Linux x86_64", "Win32"])(
+ "uses ctrlKey on non-macOS platform %s",
+ (platform) => {
+ mockPlatform(platform);
+ expect(getPanZoomModifier()).toBe("ctrlKey");
+
+ const spec = { mark: "point" } as VegaLiteSpec;
+ const newSpec = makeSelectable(spec, {});
+ const panZoom = newSpec.params?.find((p) => p.name === "pan_zoom");
+ invariant(panZoom && "select" in panZoom, "expected pan_zoom param");
+ const select = panZoom.select as { on: string; zoom: string };
+ // Must not use metaKey, which maps to the Super/Windows key here and is
+ // captured by the OS/desktop environment before the chart sees it.
+ expect(select.on).toContain("event.ctrlKey");
+ expect(select.on).not.toContain("event.metaKey");
+ expect(select.zoom).toBe("wheel![event.ctrlKey]");
+ },
+ );
+
+ it("keeps point/interval selection gated on the same modifier as pan/zoom", () => {
+ mockPlatform("Linux x86_64");
+ const spec = { mark: "bar" } as VegaLiteSpec;
+ const newSpec = makeSelectable(spec, {});
+ const mod = getPanZoomModifier();
+
+ for (const param of newSpec.params ?? []) {
+ if (!("select" in param) || typeof param.select !== "object") {
+ continue;
+ }
+ const select = param.select as { on?: string; translate?: string };
+ // The selection gating and pan/zoom must agree on the modifier, otherwise
+ // one gesture triggers both.
+ if (typeof select.on === "string" && select.on.includes("event.")) {
+ expect(select.on).toContain(`event.${mod}`);
+ }
+ }
+ });
+});
diff --git a/frontend/src/plugins/impl/vega/params.ts b/frontend/src/plugins/impl/vega/params.ts
index 5131e40143..12f6f1b3eb 100644
--- a/frontend/src/plugins/impl/vega/params.ts
+++ b/frontend/src/plugins/impl/vega/params.ts
@@ -2,6 +2,7 @@
import type { TopLevelSpec } from "vega-lite";
import type { NonNormalizedSpec } from "vega-lite/types_unstable/spec/index.js";
+import { isPlatformMac } from "@/core/hotkeys/shortcuts";
import { uniq } from "@/utils/arrays";
import { Marks } from "./marks";
import {
@@ -51,6 +52,21 @@ export const ParamNames = {
},
};
+/**
+ * The keyboard modifier used to gate pan/zoom (and to exclude it from
+ * point/interval selection).
+ *
+ * On macOS we use the Command key (`metaKey`), which is conflict-free. On other
+ * platforms `metaKey` maps to the Super/Windows key, which GNOME/Wayland and
+ * Windows reserve for system actions (workspace switching, the activities
+ * overview, etc.), so pan/zoom never reaches the chart. We fall back to the
+ * Control key there, matching the common convention for chart pan/zoom on
+ * Linux and Windows. See https://github.com/marimo-team/marimo/issues/3812.
+ */
+export function getPanZoomModifier(): "metaKey" | "ctrlKey" {
+ return isPlatformMac() ? "metaKey" : "ctrlKey";
+}
+
export const Params = {
highlight() {
return {
@@ -62,6 +78,7 @@ export const Params = {
spec: VegaLiteUnitSpec,
layerNum: number | undefined,
): SelectionParameter<"interval"> {
+ const mod = getPanZoomModifier();
return {
name: ParamNames.interval(layerNum),
select: {
@@ -73,10 +90,9 @@ export const Params = {
stroke: "#669EFF",
strokeOpacity: 0.4,
},
- // So this does not conflict with pan/zoom via metaKey
- on: "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
- translate:
- "[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",
+ // So this does not conflict with pan/zoom, which uses the same modifier
+ on: `[mousedown[!event.${mod}], mouseup] > mousemove[!event.${mod}]`,
+ translate: `[mousedown[!event.${mod}], mouseup] > mousemove[!event.${mod}]`,
},
};
},
@@ -89,7 +105,7 @@ export const Params = {
select: {
type: "point",
encodings: getEncodingAxisForMark(spec),
- on: "click[!event.metaKey]",
+ on: `click[!event.${getPanZoomModifier()}]`,
},
};
},
@@ -103,7 +119,7 @@ export const Params = {
name: ParamNames.binColoring(layerNum),
select: {
type: "point",
- on: "click[!event.metaKey]",
+ on: `click[!event.${getPanZoomModifier()}]`,
},
};
},
@@ -118,15 +134,15 @@ export const Params = {
};
},
panZoom(): SelectionParameter<"interval"> {
+ const mod = getPanZoomModifier();
return {
name: ParamNames.PAN_ZOOM,
bind: "scales",
select: {
type: "interval",
- on: "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- translate:
- "[mousedown[event.metaKey], window:mouseup] > window:mousemove!",
- zoom: "wheel![event.metaKey]",
+ on: `[mousedown[event.${mod}], window:mouseup] > window:mousemove!`,
+ translate: `[mousedown[event.${mod}], window:mouseup] > window:mousemove!`,
+ zoom: `wheel![event.${mod}]`,
},
};
},
diff --git a/frontend/src/plugins/impl/vega/vega-component.tsx b/frontend/src/plugins/impl/vega/vega-component.tsx
index a9049df826..64054062ed 100644
--- a/frontend/src/plugins/impl/vega/vega-component.tsx
+++ b/frontend/src/plugins/impl/vega/vega-component.tsx
@@ -13,6 +13,7 @@ import { tooltipHandler } from "@/components/charts/tooltip";
import type { SignalListener } from "@/components/charts/types";
import { Alert, AlertTitle } from "@/components/ui/alert";
import { Tooltip } from "@/components/ui/tooltip";
+import { isPlatformMac } from "@/core/hotkeys/shortcuts";
import { useAsyncData } from "@/hooks/useAsyncData";
import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";
import { useTheme } from "@/theme/useTheme";
@@ -229,9 +230,13 @@ const LoadedVegaComponent = ({
}
if (ParamNames.hasPanZoom(names)) {
+ // On macOS pan/zoom is gated behind the Command key; elsewhere the
+ // Super/Windows key is reserved by the OS, so we use Control instead.
+ // Keep this in sync with `getPanZoomModifier` in params.ts.
+ const modifierKey = isPlatformMac() ? "⌘" : "ctrl";
hints.push(
- ["Pan", "hold the meta key and drag"],
- ["Zoom", "hold the meta key and scroll"],
+ ["Pan", `hold the ${modifierKey} key and drag`],
+ ["Zoom", `hold the ${modifierKey} key and scroll`],
);
}