Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Update react-grid-layout and react-resizeable (#70760)

Nick Fitzpatrick2b11a3bed299
diff --git a/bun.lock b/bun.lock
index 634eea239d8..70e093ee4d8 100644
--- a/bun.lock
+++ b/bun.lock
@@ -137,12 +137,12 @@
"react-dnd-html5-backend": "4",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
- "react-grid-layout": "^1.4.4",
+ "react-grid-layout": "^1.5.3",
"react-innertext": "^1.1.5",
"react-is": "^18.2.0",
"react-markdown": "^9.0.0",
"react-redux": "^9.1.2",
- "react-resizable": "^3.0.5",
+ "react-resizable": "^3.1.3",
"react-router": "3",
"react-router-redux": "^4.0.8",
"react-transition-group": "^4.4.5",
@@ -4504,13 +4504,13 @@
"react-dom": ["[email protected]", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.0" } }, "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g=="],
- "react-draggable": ["[email protected]", "", { "dependencies": { "clsx": "^1.1.1", "prop-types": "^15.8.1" } }, "sha512-LtY5Xw1zTPqHkVmtM3X8MUOxNDOUhv/khTgBgrUvwaS064bwVvxT+q5El0uUFNx5IEPKXuRejr7UqLwBIg5pdw=="],
+ "react-draggable": ["[email protected]", "", { "dependencies": { "clsx": "^2.1.1", "prop-types": "^15.8.1" }, "peerDependencies": { "react": ">= 16.3.0", "react-dom": ">= 16.3.0" } }, "sha512-VC+HBLEZ0XJxnOxVAZsdRi8rD04Iz3SiiKOoYzamjylUcju/hP9np/aZdLHf/7WOD268WMoNJMvYfB5yAK45cw=="],
"react-dropzone": ["[email protected]", "", { "dependencies": { "attr-accept": "^2.2.2", "file-selector": "^0.6.0", "prop-types": "^15.8.1" } }, "sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug=="],
"react-fast-compare": ["[email protected]", "", {}, "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw=="],
- "react-grid-layout": ["[email protected]", "", { "dependencies": { "clsx": "^2.0.0", "fast-equals": "^4.0.3", "prop-types": "^15.8.1", "react-draggable": "^4.4.5", "react-resizable": "^3.0.5", "resize-observer-polyfill": "^1.5.1" } }, "sha512-WBKX7w/LsTfI99WskSu6nX2nbJAUD7GD6nIXcwYLyPpnslojtmql2oD3I2g5C3AK8hrxIarYT8awhuDIp7iQ5w=="],
+ "react-grid-layout": ["[email protected]", "", { "dependencies": { "clsx": "^2.1.1", "fast-equals": "^4.0.3", "prop-types": "^15.8.1", "react-draggable": "^4.4.6", "react-resizable": "^3.0.5", "resize-observer-polyfill": "^1.5.1" }, "peerDependencies": { "react": ">= 16.3.0", "react-dom": ">= 16.3.0" } }, "sha512-KaG6IbjD6fYhagUtIvOzhftXG+ViKZjCjADe86X1KHl7C/dsBN2z0mi14nbvZKTkp0RKiil9RPcJBgq3LnoA8g=="],
"react-innertext": ["[email protected]", "", {}, "sha512-PWAqdqhxhHIv80dT9znP2KvS+hfkbRovFp4zFYHFFlOoQLRiawIic81gKb3U1wEyJZgMwgs3JoLtwryASRWP3Q=="],
@@ -4532,7 +4532,7 @@
"react-remove-scroll-bar": ["[email protected]", "", { "dependencies": { "react-style-singleton": "^2.2.2", "tslib": "^2.0.0" } }, "sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q=="],
- "react-resizable": ["[email protected]", "", { "dependencies": { "prop-types": "15.x", "react-draggable": "^4.0.3" } }, "sha512-vKpeHhI5OZvYn82kXOs1bC8aOXktGU5AmKAgaZS4F5JPburCtbmDPqE7Pzp+1kN4+Wb81LlF33VpGwWwtXem+w=="],
+ "react-resizable": ["[email protected]", "", { "dependencies": { "prop-types": "15.x", "react-draggable": "^4.5.0" }, "peerDependencies": { "react": ">= 16.3", "react-dom": ">= 16.3" } }, "sha512-liJBNayhX7qA4tBJiBD321FDhJxgGTJ07uzH5zSORXoE8h7PyEZ8mLqmosST7ppf6C4zUsbd2gzDMmBCfFp9Lw=="],
"react-router": ["[email protected]", "", { "dependencies": { "create-react-class": "^15.5.1", "history": "^3.0.0", "hoist-non-react-statics": "^3.3.2", "invariant": "^2.2.1", "loose-envify": "^1.2.0", "prop-types": "^15.7.2", "react-is": "^16.13.0", "warning": "^3.0.0" } }, "sha512-nlxtQE8B22hb/JxdaslI1tfZacxFU8x8BJryXOnR2RxB4vc01zuHYAHAIgmBkdk1kzXaA25hZxK6KAH/+CXArw=="],
@@ -6534,8 +6534,6 @@
"mdast-util-to-markdown/@types/unist": ["@types/[email protected]", "", {}, "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="],
- "micromatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
-
"miller-rabin/bn.js": ["[email protected]", "", {}, "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw=="],
"mini-css-extract-plugin/schema-utils": ["[email protected]", "", { "dependencies": { "@types/json-schema": "^7.0.9", "ajv": "^8.8.0", "ajv-formats": "^2.1.1", "ajv-keywords": "^5.0.0" } }, "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg=="],
diff --git a/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js b/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js
index 1f7a8d2af47..a2b98835e79 100644
--- a/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js
@@ -242,6 +242,70 @@ describe(
});
});
+ it("should keep the resize handle connected to the cursor while resizing (metabase#70451)", () => {
+ H.createDashboardWithQuestions({
+ dashboardDetails: {},
+ questions: [
+ {
+ display: "table",
+ query: {
+ "source-table": ORDERS_ID,
+ limit: 10,
+ },
+ },
+ ],
+ }).then(({ dashboard }) => {
+ H.visitDashboard(dashboard.id);
+ });
+
+ H.editDashboard();
+
+ let targetX, targetY;
+
+ H.getDashboardCard(0)
+ .find(".react-resizable-handle")
+ .then(($handle) => {
+ const rect = $handle[0].getBoundingClientRect();
+ const startX = Math.round(rect.left + rect.width / 2);
+ const startY = Math.round(rect.top + rect.height / 2);
+ targetX = startX + 200;
+ targetY = startY + 150;
+
+ // Not using the wrapper here because we want to avoid waits and we need the starting position for later
+ cy.wrap($handle)
+ .trigger("mousedown", {
+ button: 0,
+ clientX: startX,
+ clientY: startY,
+ force: true,
+ })
+ .trigger("mousemove", {
+ clientX: targetX,
+ clientY: targetY,
+ force: true,
+ });
+ });
+
+ // After dragging, the resize handle should still be near the cursor position.
+ H.getDashboardCard(0)
+ .find(".react-resizable-handle")
+ .then(($handle) => {
+ const rect = $handle[0].getBoundingClientRect();
+ const handleCenterX = Math.round(rect.left + rect.width / 2);
+ const handleCenterY = Math.round(rect.top + rect.height / 2);
+
+ const maxDrift = 50;
+ expect(
+ Math.abs(handleCenterX - targetX),
+ `Horizontal drift: handle at ${handleCenterX}, cursor at ${targetX}`,
+ ).to.be.lessThan(maxDrift);
+ expect(
+ Math.abs(handleCenterY - targetY),
+ `Vertical drift: handle at ${handleCenterY}, cursor at ${targetY}`,
+ ).to.be.lessThan(maxDrift);
+ });
+ });
+
it("should not allow cards to be resized smaller than min height", () => {
const cardIds = [];
TEST_QUESTIONS.forEach((question) => {
diff --git a/e2e/test/scenarios/dashboard-cards/dashboard-sections.cy.spec.js b/e2e/test/scenarios/dashboard-cards/dashboard-sections.cy.spec.js
index 7ae6646bb45..d8676f27430 100644
--- a/e2e/test/scenarios/dashboard-cards/dashboard-sections.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-cards/dashboard-sections.cy.spec.js
@@ -58,12 +58,12 @@ describe("scenarios > dashboard cards > sections", () => {
selectQuestion("Orders, Count, Grouped by Created At (year)");
overwriteDashCardTitle(
- 1,
+ 2,
"Orders, Count, Grouped by Created At (year)",
"Line chart",
);
// TODO: if the mapping is done before the title is changed, the mapping is lost
- mapDashCardToFilter(H.getDashboardCard(1), "Category");
+ mapDashCardToFilter(H.getDashboardCard(2), "Category");
H.goToTab("Tab 1");
H.saveDashboard();
@@ -101,7 +101,7 @@ describe("scenarios > dashboard cards > sections", () => {
// Ensure parameter mapping is persisted
H.editDashboard();
filterPanel().findByText("Category").click();
- H.getDashboardCard(1).findByText("Product.Category").should("exist");
+ H.getDashboardCard(2).findByText("Product.Category").should("exist");
});
});
diff --git a/package.json b/package.json
index dbc41f7ea5e..254d1152eaa 100644
--- a/package.json
+++ b/package.json
@@ -142,12 +142,12 @@
"react-dnd-html5-backend": "4",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
- "react-grid-layout": "^1.4.4",
+ "react-grid-layout": "^1.5.3",
"react-innertext": "^1.1.5",
"react-is": "^18.2.0",
"react-markdown": "^9.0.0",
"react-redux": "^9.1.2",
- "react-resizable": "^3.0.5",
+ "react-resizable": "^3.1.3",
"react-router": "3",
"react-router-redux": "^4.0.8",
"react-transition-group": "^4.4.5",