Skip to content

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

fix: scroll position jump when entering field sort mode gdgt-1269 (#66318)

Jakub Chodorowicz0400e1bf075f
diff --git a/e2e/support/helpers/e2e-datamodel-helpers.ts b/e2e/support/helpers/e2e-datamodel-helpers.ts
index c9e751e93b3..6e1bcc08a86 100644
--- a/e2e/support/helpers/e2e-datamodel-helpers.ts
+++ b/e2e/support/helpers/e2e-datamodel-helpers.ts
@@ -248,27 +248,27 @@ function getTableDescriptionInput() {
}
function getTableSortButton() {
- return getTableSection().button(/Sorting/);
+ return getTableSection().findByRole("button", { name: "Sorting" });
}
function getTableSortDoneButton() {
- return getTableSection().button(/Done/);
+ return getTableSection().findByRole("button", { name: "Done" });
}
function getTableSortOrderInput() {
- return getTableSection().findByLabelText("Column order");
+ return getTableSection().findByRole("radiogroup", { name: "Column order" });
}
function getTableSyncOptionsButton() {
- return getTableSection().button(/Sync/);
+ return getTableSection().findByRole("button", { name: /Sync/ });
}
function getTableSectionField(name: string) {
- return getTableSection().findByLabelText(name);
+ return getTableSection().findByRole("listitem", { name });
}
function getTableSectionSortableField(name: string) {
- return getTableSection().findByLabelText(name);
+ return getTableSection().findByRole("listitem", { name });
}
function getTableSectionSortableFields() {
@@ -276,7 +276,7 @@ function getTableSectionSortableFields() {
}
function getTableSectionVisibilityTypeInput() {
- return getTableSection().findByLabelText("Visibility type");
+ return getTableSection().findByRole("textbox", { name: "Visibility type" });
}
function getTableSectionFieldNameInput(name: string) {
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/components/TableSection/TableSection.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/components/TableSection/TableSection.tsx
index ef97057c0c5..7c5c6bedab1 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/components/TableSection/TableSection.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/components/TableSection/TableSection.tsx
@@ -278,23 +278,34 @@ const TableSectionBase = ({
{!hasFields && <EmptyState message={t`This table has no fields`} />}
+ {/* NOTE: We're using here CSS display property to avoid scroll jump when toggling sorting mode. */}
{hasFields && (
<>
- {isSorting && (
+ <Box
+ style={{
+ display: isSorting ? "block" : "none",
+ }}
+ aria-hidden={!isSorting}
+ >
<TableSortableFieldList
activeFieldId={activeFieldId}
table={table}
onChange={handleCustomFieldOrderChange}
/>
- )}
+ </Box>
- {!isSorting && (
+ <Box
+ style={{
+ display: isSorting ? "none" : "block",
+ }}
+ aria-hidden={isSorting}
+ >
<TableFieldList
table={table}
activeFieldId={activeFieldId}
getFieldHref={getFieldHref}
/>
- )}
+ </Box>
</>
)}
</Stack>
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/pages/DataModel/DataModel.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/pages/DataModel/DataModel.unit.spec.tsx
index 3ccc292bf99..c2a083fc5c8 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/pages/DataModel/DataModel.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/data-model/pages/DataModel/DataModel.unit.spec.tsx
@@ -988,7 +988,7 @@ function getTableSection() {
}
function getTableSectionField(name: string) {
- return within(getTableSection()).getByLabelText(name);
+ return within(getTableSection()).getByRole("listitem", { name });
}
function getTableSectionFieldNameInput(name: string) {