Skip to content

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

UXW-175 Fix visualization mode switch for pivot table (#65252)

Denis Berezin3ca4c5a2ee02
diff --git a/e2e/support/helpers/e2e-ui-elements-helpers.js b/e2e/support/helpers/e2e-ui-elements-helpers.js
index bfcbb66d520..d7064a6295d 100644
--- a/e2e/support/helpers/e2e-ui-elements-helpers.js
+++ b/e2e/support/helpers/e2e-ui-elements-helpers.js
@@ -254,6 +254,10 @@ export const queryBuilderFooter = () => {
return cy.findByTestId("view-footer");
};
+export const queryBuilderFooterDisplayToggle = () => {
+ return cy.findByTestId("query-display-tabular-toggle");
+};
+
export const closeQuestionActions = () => {
queryBuilderHeader().click();
};
diff --git a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
index 868ead786f2..a66aa9bf36d 100644
--- a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
@@ -1548,3 +1548,52 @@ describe("issue 63745", () => {
});
});
});
+
+describe("issue 56094", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ });
+
+ it("should allow to switch between automatic pivot table and usual table visualization (metabase#56094)", () => {
+ H.visitQuestionAdhoc({
+ name: "56094",
+ dataset_query: {
+ type: "query",
+ database: SAMPLE_DB_ID,
+ query: {
+ "source-table": PRODUCTS_ID,
+ aggregation: [["count"]],
+ breakout: [
+ [
+ "field",
+ PRODUCTS.CATEGORY,
+ {
+ "base-type": "type/Text",
+ },
+ ],
+ [
+ "field",
+ PRODUCTS.RATING,
+ {
+ binning: {
+ strategy: "default",
+ },
+ },
+ ],
+ ],
+
+ limit: 20,
+ },
+ },
+ });
+
+ H.queryBuilderFooter().findByLabelText("Switch to data").click();
+
+ H.queryBuilderFooterDisplayToggle().should("exist");
+
+ H.queryBuilderFooter().findByLabelText("Switch to visualization").click();
+
+ H.queryBuilderFooterDisplayToggle().should("exist");
+ });
+});
diff --git a/frontend/src/metabase/query_builder/components/view/QuestionDisplayToggle/QuestionDisplayToggle.tsx b/frontend/src/metabase/query_builder/components/view/QuestionDisplayToggle/QuestionDisplayToggle.tsx
index 4b342a35ffe..a3ade82d09f 100644
--- a/frontend/src/metabase/query_builder/components/view/QuestionDisplayToggle/QuestionDisplayToggle.tsx
+++ b/frontend/src/metabase/query_builder/components/view/QuestionDisplayToggle/QuestionDisplayToggle.tsx
@@ -49,6 +49,7 @@ const QuestionDisplayToggle = ({
}}
tabIndex={0}
value={isShowingRawTable ? "data" : "visualization"}
+ data-testid="query-display-tabular-toggle"
data={[
{
disabled: true,
diff --git a/frontend/src/metabase/query_builder/selectors.js b/frontend/src/metabase/query_builder/selectors.js
index f6a6e0d6e26..d144cf2c701 100644
--- a/frontend/src/metabase/query_builder/selectors.js
+++ b/frontend/src/metabase/query_builder/selectors.js
@@ -941,7 +941,9 @@ export const getIsVisualized = createSelector(
((question.display() !== "table" &&
question.display() !== "pivot" &&
question.display() !== "list") ||
- (settings != null && settings["table.pivot"])),
+ (settings != null &&
+ (settings["table.pivot"] ||
+ (question.display() === "table" && settings["table.pivot_column"])))), // last case - pivot_column is set but display is set to table viz (#56094)
);
export const getIsLiveResizable = createSelector(