The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
feat(sdk,embed-js): Add touch device support for collection name description icon (#71762)
Timofey Kachalova6453de48dff
diff --git a/e2e/test-component/scenarios/embedding-sdk/touch-collection-browser.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/touch-collection-browser.cy.spec.tsxnew file mode 100644index 00000000000..bbf6de7db05--- /dev/null+++ b/e2e/test-component/scenarios/embedding-sdk/touch-collection-browser.cy.spec.tsx@@ -0,0 +1,66 @@+import { CollectionBrowser } from "@metabase/embedding-sdk-react";++import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";+import { createQuestion } from "e2e/support/helpers";+import { getSdkRoot } from "e2e/support/helpers/e2e-embedding-sdk-helpers";+import {+ disableTouchEmulation,+ enableTouchEmulation,+} from "e2e/support/helpers/e2e-mobile-device-helpers";+import { mountSdkContent } from "e2e/support/helpers/embedding-sdk-component-testing/component-embedding-sdk-helpers";+import { signInAsAdminAndEnableEmbeddingSdk } from "e2e/support/helpers/embedding-sdk-testing";+import { mockAuthProviderAndJwtSignIn } from "e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers";++const { ORDERS_ID } = SAMPLE_DATABASE;++const QUESTION_DESCRIPTION = "This is a test description for the question";++describe("scenarios > embedding-sdk > touch collection browser", () => {+ beforeEach(() => {+ signInAsAdminAndEnableEmbeddingSdk();++ createQuestion({+ name: "Question with description",+ description: QUESTION_DESCRIPTION,+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ display: "scalar",+ collection_id: null,+ });++ cy.signOut();+ mockAuthProviderAndJwtSignIn();+ });++ describe("touch device", () => {+ beforeEach(() => {+ cy.viewport("iphone-x");+ enableTouchEmulation();+ });++ afterEach(() => {+ disableTouchEmulation();+ });++ it("should show description tooltip on info icon tap without navigating to the item", () => {+ mountSdkContent(<CollectionBrowser collectionId="root" />);++ getSdkRoot().within(() => {+ cy.findByText("Question with description").should("be.visible");++ cy.findByText("Question with description")+ .closest("tr")+ .findByLabelText("info icon")+ .click();+ });++ cy.findByRole("tooltip").should("contain.text", QUESTION_DESCRIPTION);++ getSdkRoot().within(() => {+ cy.findByText("Question with description").should("be.visible");+ });+ });+ });+});diff --git a/frontend/src/metabase/common/components/ItemsTable/Columns.tsx b/frontend/src/metabase/common/components/ItemsTable/Columns.tsxindex 1bced02388a..465e261de25 100644--- a/frontend/src/metabase/common/components/ItemsTable/Columns.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/Columns.tsx@@ -10,6 +10,7 @@ import { Markdown } from "metabase/common/components/Markdown";import { ArchiveButton } from "metabase/embedding/components/ArchiveButton";import { isEmbeddingSdk } from "metabase/embedding-sdk/config";import { useTranslateContent } from "metabase/i18n/hooks";+import { isTouchDevice } from "metabase/lib/browser";import { modelToUrl } from "metabase/lib/urls";import { getUserName } from "metabase/lib/user";import { PLUGIN_MODERATION } from "metabase/plugins";@@ -184,6 +185,13 @@ export const Columns = {{tc(item.description)}</Markdown>}+ onClick={(event) => {+ // On mobile devices we allow clicking on the icon to show the description+ if (isTouchDevice()) {+ event.stopPropagation();+ event.preventDefault();+ }+ }}/>)}</ItemLinkComponent>