Skip to content

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

Gdgt 1864 Add pinned columns and rows to the DataGrid (#70384)

Egor Grushin7a7585be68c4
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png
index 02795a677e3..0a811a31f7a 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png
index e4c0ed8e05b..dfba00667b9 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png
index 68d084fc491..d40fc5de702 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png
index 2d3fb2d2c3b..9f25f357bd8 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png
index aced89a189b..33645bd4dcb 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png
index e273bbee9fe..677e38dedb1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png
index 5982034bee1..f2ac9518818 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png
index 7134a6c9926..2be47117c9b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png
index 61eae389bec..18386e13712 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png
index 0c8878f5b21..34a418e53ac 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png
index 44906c41520..5abc007e8b2 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png
index 62c6c1da77f..681e7178987 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png
index 2f87882b2b6..1d2475ff63a 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png
index 0da15492ab0..c6e8cef1d37 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png
index f03ed8097a4..c449662a3d4 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png
index 4bf397c84c4..f58800422c6 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png
index 0611f7dfa4a..e3b179c1d91 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png
index 54f71d54dd0..3916acef411 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png
index dc92ee17d42..9cf9ec198f1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png
index c8e6efe6229..fbdd597775b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png
index e15a8a89486..9870af7c001 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png
index f565dc03e29..29a3f1adf33 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png
index 5d22d3ae2e5..a54152d608c 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png
index e15a8a89486..9870af7c001 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png
index 0dfc9cf7c1d..4677eccd0ef 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png
index 1582755b6b3..b0236466a8c 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png
index 1582755b6b3..b0236466a8c 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png
index 00f5370090d..ea17bec674c 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png
index cf13f1ce89d..79f7979326d 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png
index a72edd28bf1..c5ed1488d0e 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png
index 61105900305..bd4035175d4 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png
index 43deb7fcc12..b6753445a7b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png
index 99d058158c1..829213f3dfb 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png
index 1ef346c16cd..013f9799c5f 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png
index 0305ec186d2..018e207db72 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png
index c3818d60636..bcadce4f091 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png
index d04e507eff8..6d1ecdb1294 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png
index 538985744bc..305c37fe886 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png
index 28048216111..e5d8938ebcc 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png
index d04e507eff8..6d1ecdb1294 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png
index 56842a425dc..62304fe8fc3 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png
index 1b2c0cd8299..2aca34be5a3 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png
index 323376b2170..2aca34be5a3 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png
index 838e83bfff6..82d5b5f0fb2 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Table_Light_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Table_Light_Theme.png
index 5e3a7e13249..aa6ddc3c055 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Table_Light_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Table_Light_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Basic_Grid.png b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Basic_Grid.png
index fc637340a21..cb8b6d3105e 100644
Binary files a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Basic_Grid.png and b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Basic_Grid.png differ
diff --git a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Combined_Features.png b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Combined_Features.png
index c4236d1a5cf..02acf9eedc3 100644
Binary files a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Combined_Features.png and b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Combined_Features.png differ
diff --git a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Selectable_Rows.png b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Selectable_Rows.png
index 11f2ef1082d..5f6ef24efb7 100644
Binary files a/.loki/reference/chrome_laptop_DataGrid_DataGrid_Selectable_Rows.png and b/.loki/reference/chrome_laptop_DataGrid_DataGrid_Selectable_Rows.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Dark.png b/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Dark.png
index 7f1b50c1488..a6a09444d7a 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Dark.png and b/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Dark.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Light.png b/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Light.png
index e4b4b97979d..d9a093ca8f5 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Light.png and b/.loki/reference/chrome_laptop_viz_Table_Conditional_Fomatting_Light.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table.png
index 2a440ae1181..36b99ab4230 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table.png and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme.png
index 070070660be..9999f292601 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme.png and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png
index b23ca8a19b0..0ea479f0559 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Sticky_Background_Color.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Sticky_Background_Color.png
index 46c5149649c..75429f9c050 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Sticky_Background_Color.png and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Sticky_Background_Color.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_With_Row_Id.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_With_Row_Id.png
index 54531e458f2..e38da97fcf8 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_With_Row_Id.png and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_With_Row_Id.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Preserve_Whitespace_Unwrapped.png b/.loki/reference/chrome_laptop_viz_Table_Preserve_Whitespace_Unwrapped.png
index 437abac88d1..c0397281f52 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Preserve_Whitespace_Unwrapped.png and b/.loki/reference/chrome_laptop_viz_Table_Preserve_Whitespace_Unwrapped.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Table_With_Images.png b/.loki/reference/chrome_laptop_viz_Table_Table_With_Images.png
index c4cd0c6ccaf..4ed4a228021 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Table_With_Images.png and b/.loki/reference/chrome_laptop_viz_Table_Table_With_Images.png differ
diff --git a/.loki/reference/chrome_laptop_viz_Table_Table_With_Wrapped_Links.png b/.loki/reference/chrome_laptop_viz_Table_Table_With_Wrapped_Links.png
index e460079806d..37b0bb4d3ea 100644
Binary files a/.loki/reference/chrome_laptop_viz_Table_Table_With_Wrapped_Links.png and b/.loki/reference/chrome_laptop_viz_Table_Table_With_Wrapped_Links.png differ
diff --git a/bun.lock b/bun.lock
index ab0c08697ae..419aed2fdb5 100644
--- a/bun.lock
+++ b/bun.lock
@@ -41,7 +41,7 @@
"@react-oauth/google": "^0.11.1",
"@reduxjs/toolkit": "^2.5.0",
"@snowplow/browser-tracker": "^3.1.6",
- "@tanstack/react-table": "^8.21.2",
+ "@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.2",
"@tippyjs/react": "^4.2.6",
"@tiptap/core": "^3.2.0",
@@ -1510,7 +1510,7 @@
"@szmarczak/http-timer": ["@szmarczak/[email protected]", "", { "dependencies": { "defer-to-connect": "^1.0.1" } }, "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA=="],
- "@tanstack/react-table": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/table-core": "8.21.2" } }, "sha512-11tNlEDTdIhMJba2RBH+ecJ9l1zgS2kjmexDPAraulc8jeNA4xocSNeyzextT0XJyASil4XsCYlJmf5jEWAtYg=="],
+ "@tanstack/react-table": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/table-core": "8.21.3" }, "peerDependencies": { "react": ">=16.8", "react-dom": ">=16.8" } }, "sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww=="],
"@tanstack/react-virtual": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/virtual-core": "3.13.2" } }, "sha512-LceSUgABBKF6HSsHK2ZqHzQ37IKV/jlaWbHm+NyTa3/WNb/JZVcThDuTainf+PixltOOcFCYXwxbLpOX9sCx+g=="],
@@ -5718,8 +5718,6 @@
"@svgr/plugin-svgo/deepmerge": ["[email protected]", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
- "@tanstack/react-table/@tanstack/table-core": ["@tanstack/[email protected]", "", {}, "sha512-uvXk/U4cBiFMxt+p9/G7yUWI/UbHYbyghLCjlpWZ3mLeIZiUBSKcUnw9UnKkdRz7Z/N4UBuFLWQdJCjUe7HjvA=="],
-
"@testing-library/jest-dom/aria-query": ["[email protected]", "", {}, "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg=="],
"@testing-library/jest-dom/chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg=="],
diff --git a/e2e/test-component/scenarios/embedding-sdk/sdk-question.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/sdk-question.cy.spec.tsx
index b9bbca9ee42..c941935a9a1 100644
--- a/e2e/test-component/scenarios/embedding-sdk/sdk-question.cy.spec.tsx
+++ b/e2e/test-component/scenarios/embedding-sdk/sdk-question.cy.spec.tsx
@@ -76,6 +76,7 @@ describe("scenarios > embedding-sdk > interactive-question", () => {
cy.findByTestId("viz-settings-button").click();
H.popover().within(() => {
+ cy.findByText("Display").click();
cy.findByText("Show row index").click();
});
@@ -85,13 +86,11 @@ describe("scenarios > embedding-sdk > interactive-question", () => {
cy.findByText("#").should("be.visible");
cy.findByTestId("table-body")
- .get("[data-index='0']")
- .within(() => {
- cy.get("[data-column-id$='_INDEX']")
- .realHover({ scrollBehavior: false })
- .findByTestId("detail-shortcut")
- .should("not.exist");
- });
+ .find("[data-column-id$='_INDEX']")
+ .eq(0)
+ .realHover({ scrollBehavior: false })
+ .findByTestId("detail-shortcut")
+ .should("not.exist");
});
});
diff --git a/e2e/test/scenarios/models/models-metadata.cy.spec.js b/e2e/test/scenarios/models/models-metadata.cy.spec.js
index 96824c6baef..bc3a2eeca78 100644
--- a/e2e/test/scenarios/models/models-metadata.cy.spec.js
+++ b/e2e/test/scenarios/models/models-metadata.cy.spec.js
@@ -301,9 +301,10 @@ describe("scenarios > models metadata", () => {
cy.findAllByTestId("header-cell")
.contains("Products → Price")
- .trigger("mousedown")
- .trigger("mousemove", { clientX: 600, clientY: 0 })
- .trigger("mouseup");
+ .closest("[data-testid='header-cell']")
+ .as("dragHeader");
+
+ H.moveDnDKitElementByAlias("@dragHeader", { horizontal: 600 });
cy.findAllByTestId("header-cell")
.contains("Products → Vendor")
diff --git a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
index a26c0a1bf74..63908e5d573 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
@@ -1140,11 +1140,7 @@ describe("issue 55487", () => {
it("should be able open object details on browser forward navigation (metabase#55487)", () => {
H.visitQuestion(ORDERS_QUESTION_ID);
- cy.findByTestId("table-body")
- .get("[data-index='4']")
- .within(() => {
- cy.get("[data-column-id='ID']").click();
- });
+ cy.findByTestId("table-body").find("[data-column-id='ID']").eq(4).click();
cy.findByTestId("object-detail").should("be.visible");
@@ -1280,46 +1276,46 @@ SELECT 2 AS ID, 3 AS USER_ID
);
});
- cy.findByTestId("table-root")
- .findAllByRole("row")
- .first()
- .within(() => {
- cy.get("[data-column-id='USER_ID']").click();
- });
+ cy.findByTestId("table-body")
+ .find("[data-column-id='USER_ID']")
+ .eq(0)
+ .click();
+
H.popover().within(() => {
cy.findByText("View Models with no User").should("be.visible").click();
});
+
cy.findByTestId("table-body").within(() => {
- cy.findAllByRole("row").should("have.length", 1);
- cy.findAllByRole("row")
+ /**
+ * each row is rendered twice, that's why we need to assert 2 instead of 1
+ */
+ cy.findAllByRole("row").should("have.length", 2);
+ cy.get("[data-column-id='USER_ID']")
.first()
- .within(() => {
- cy.get("[data-column-id='USER_ID']").within(() => {
- cy.get("[data-testid=cell-data]").should("not.exist");
- });
- });
+ .find("[data-testid=cell-data]")
+ .should("not.exist");
});
H.visitQuestion("@questionId");
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='USER_ID']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='USER_ID']").click();
- });
+ .click();
+
H.popover().within(() => {
cy.findByText("View this User's Models").should("be.visible").click();
});
+
cy.findByTestId("table-body").within(() => {
- cy.findAllByRole("row").should("have.length", 1);
- cy.findAllByRole("row")
+ /**
+ * each row is rendered twice, that's why we need to assert 2 instead of 1
+ */
+ cy.findAllByRole("row").should("have.length", 2);
+ cy.get("[data-column-id='USER_ID']")
.first()
- .within(() => {
- cy.get("[data-column-id='USER_ID']").within(() => {
- cy.get("[data-testid=cell-data]").should("have.text", "3");
- });
- });
+ .find("[data-testid=cell-data]")
+ .should("have.text", "3");
});
});
});
diff --git a/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts b/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
index 5050de95c26..5975341fe62 100644
--- a/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
+++ b/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
@@ -307,12 +307,11 @@ describe("scenarios > table-editing", () => {
cases.forEach(({ dataType, column, value }) => {
it(`should allow to edit a cell with type ${dataType}`, () => {
// Locate the table and the specific cell to edit
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find(`[data-column-id='${column}']`)
.eq(1) // Select the second row (index 1)
- .within(() => {
- cy.get(`[data-column-id='${column}']`).as("targetCell").click(); // Activate inline editing
- });
+ .as("targetCell")
+ .click(); // Activate inline editing
// Edit the cell value
cy.get("@targetCell")
@@ -351,14 +350,11 @@ describe("scenarios > table-editing", () => {
});
it("should allow to edit a cell with date type", () => {
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='date']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='date']").as("targetCell").click({
- scrollBehavior: false,
- });
- });
+ .as("targetCell")
+ .click({ scrollBehavior: false });
const day = Math.floor(Math.random() * 10) + 10; // 10-20
@@ -379,14 +375,11 @@ describe("scenarios > table-editing", () => {
});
it("should allow to edit a cell with datetime type", () => {
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='datetime']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='datetime']").as("targetCell").click({
- scrollBehavior: false,
- });
- });
+ .as("targetCell")
+ .click({ scrollBehavior: false });
const day = Math.floor(Math.random() * 10) + 10; // 10-20
const hour = Math.floor(Math.random() * 12);
@@ -423,14 +416,11 @@ describe("scenarios > table-editing", () => {
});
it("should allow to edit a cell with select type", () => {
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='boolean']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='boolean']").as("targetCell").click({
- scrollBehavior: false,
- });
- });
+ .as("targetCell")
+ .click({ scrollBehavior: false });
H.popover().within(() => {
// 3: true, false, null
@@ -445,37 +435,27 @@ describe("scenarios > table-editing", () => {
});
it("should not allow to edit PK cells", () => {
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='id']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='id']")
- .as("targetCell")
- .click({
- scrollBehavior: false,
- })
- .find("input")
- .should("not.exist");
- });
+ .as("targetCell")
+ .click({ scrollBehavior: false })
+ .find("input")
+ .should("not.exist");
});
it("should handle errors", () => {
- cy.findByTestId("table-root")
- .findAllByRole("row")
+ cy.findByTestId("table-body")
+ .find("[data-column-id='tinyint']")
.eq(1)
- .within(() => {
- cy.get("[data-column-id='tinyint']")
- .as("targetCell")
- .click({
- scrollBehavior: false,
- })
- .find("input")
- // Entering a big number into tinyint column
- .type("{selectAll}{backspace}9999999", {
- scrollBehavior: false,
- })
- .blur(); // Trigger the save action by blurring the input
- });
+ .as("targetCell")
+ .click({ scrollBehavior: false })
+ .find("input")
+ // Entering a big number into tinyint column
+ .type("{selectAll}{backspace}9999999", {
+ scrollBehavior: false,
+ })
+ .blur(); // Trigger the save action by blurring the input
H.undoToast()
.findByText("Couldn't save table changes")
@@ -676,8 +656,19 @@ function openTableEdit(tableName: RegExp) {
function openEditRowModal(rowIndex: number) {
cy.findByTestId("table-root")
.findAllByRole("row")
- .should("have.length.gte", 2)
- .eq(rowIndex)
+ .should("have.length.gte", 4)
+ .filter((_, el) => rowIndex === Number(el.dataset.datasetIndex))
+ .as("rowSections");
+
+ cy.get("@rowSections")
+ .eq(0)
+ .within(() => {
+ cy.get("[data-column-id]").first().realHover();
+ cy.findByTestId("row-edit-icon").click();
+ });
+
+ cy.get("@rowSections")
+ .eq(1)
.within(() => {
cy.findAllByTestId("cell-data")
.eq(0)
@@ -685,10 +676,6 @@ function openEditRowModal(rowIndex: number) {
.then((text) => {
cy.wrap(text).as("rowId");
});
-
- cy.findAllByTestId("cell-data").first().realHover();
-
- cy.findByTestId("row-edit-icon").click();
});
H.modal().findByText("Edit record").should("be.visible");
diff --git a/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js
index ca6f6653379..174c9c0cdb4 100644
--- a/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/table-column-settings.cy.spec.js
@@ -937,6 +937,111 @@ describe("scenarios > visualizations > table column settings", () => {
});
});
+ describe("column pinning", () => {
+ describe("column reordering between pinned and unpinned sections", () => {
+ it("should allow reordering a column from the unpinned section into the pinned section", () => {
+ H.createQuestion(
+ {
+ query: { "source-table": ORDERS_ID },
+ visualization_settings: {
+ "table.freeze_columns": true,
+ "table.freeze_columns_count": 1,
+ },
+ },
+ { visitQuestion: true },
+ );
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 1)
+ .first()
+ .should("contain.text", "ID");
+
+ H.tableHeaderColumn("User ID").as("dragElement");
+ H.moveDnDKitElementByAlias("@dragElement", { horizontal: -50 });
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 1)
+ .first()
+ .should("contain.text", "User ID");
+ });
+
+ it("should allow reordering a column from the pinned section into the unpinned section", () => {
+ H.createQuestion(
+ {
+ query: { "source-table": ORDERS_ID },
+ visualization_settings: {
+ "table.freeze_columns": true,
+ "table.freeze_columns_count": 2,
+ },
+ },
+ { visitQuestion: true },
+ );
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 2)
+ .then((cells) => {
+ expect(cells.eq(0)).to.contain("ID");
+ expect(cells.eq(1)).to.contain("User ID");
+ });
+
+ H.tableHeaderColumn("ID").as("dragElement");
+ H.moveDnDKitElementByAlias("@dragElement", { horizontal: 400 });
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .then((cells) => {
+ expect(cells.eq(0)).to.contain("User ID");
+ expect(cells.eq(1)).to.contain("Product ID");
+ });
+ });
+ });
+
+ describe("column resizing with pinning limits", () => {
+ it("should unpin/re-pin the last pinned column when resizing exceeds/fits 90% of container width", () => {
+ H.createQuestion(
+ {
+ query: { "source-table": ORDERS_ID },
+ visualization_settings: {
+ "table.freeze_columns": true,
+ "table.freeze_columns_count": 4,
+ },
+ },
+ { visitQuestion: true },
+ );
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 4);
+
+ cy.findByTestId("table-scroll-container")
+ .invoke("width")
+ .then((containerWidth) => {
+ const moveX = containerWidth * 0.7;
+ H.resizeTableColumn("ID", moveX);
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 2);
+
+ H.resizeTableColumn("ID", -moveX);
+
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 4);
+
+ // allow resizing columns in the pinned section without affecting pinning when within limits
+ H.resizeTableColumn("ID", 30);
+ cy.findByTestId("header-pinned-quadrant")
+ .findAllByTestId("header-cell")
+ .should("have.length", 4);
+ });
+ });
+ });
+ });
+
it("should respect date_style column setting for week temporal unit", () => {
const questionWithWeekBreakout = {
display: "table",
diff --git a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
index 09a0ddcc7eb..6de5ab68831 100644
--- a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
@@ -151,6 +151,7 @@ describe("scenarios > visualizations > table", () => {
it("should allow enabling row index column", () => {
H.openOrdersTable();
H.openVizSettingsSidebar();
+ H.sidebar().findByText("Display").click();
H.sidebar().findByText("Show row index").click();
H.openObjectDetail(5);
@@ -607,6 +608,40 @@ describe("scenarios > visualizations > table > dashboards context", () => {
cy.get(idCellSelector).should("contain", secondPageId);
});
+ it("should display pinned rows correctly with pagination", () => {
+ H.createQuestionAndDashboard({
+ questionDetails: {
+ display: "table",
+ query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },
+ visualization_settings: {
+ "table.freeze_rows": true,
+ "table.freeze_rows_count": 1,
+ "table.pagination": true,
+ },
+ },
+ cardDetails: {
+ size_x: 24,
+ size_y: 12,
+ },
+ }).then(({ body: { dashboard_id } }) => {
+ H.visitDashboard(dashboard_id);
+ });
+
+ cy.findByTestId("pinned-center-quadrant")
+ .findByRole("row")
+ .find("[data-column-id=ID]")
+ .findByTestId("cell-data")
+ .should("have.text", "1");
+
+ cy.findByLabelText("Next page").click();
+
+ cy.findByTestId("pinned-center-quadrant")
+ .findByRole("row")
+ .find("[data-column-id=ID]")
+ .findByTestId("cell-data")
+ .should("have.text", "1");
+ });
+
it("should support text wrapping setting", () => {
H.createQuestionAndDashboard({
questionDetails: {
@@ -795,6 +830,7 @@ describe("scenarios > visualizations > table > dashboards context", () => {
.within(() => {
cy.findByLabelText("Show visualization options").click();
});
+ H.modal().findByText("Display").click();
H.modal().findByText("Show row index").click();
cy.button("Done").click();
@@ -815,6 +851,47 @@ describe("scenarios > visualizations > table > dashboards context", () => {
.should("have.text", 1);
});
+ it("should sort pinned rows correctly with client-side sorting", () => {
+ H.createQuestionAndDashboard({
+ questionDetails: {
+ display: "table",
+ query: { "source-table": SAMPLE_DATABASE.ORDERS_ID },
+ visualization_settings: {
+ "table.freeze_rows": true,
+ "table.freeze_rows_count": 1,
+ },
+ },
+ cardDetails: {
+ size_x: 24,
+ size_y: 12,
+ },
+ }).then(({ body: { dashboard_id } }) => {
+ H.visitDashboard(dashboard_id);
+ });
+
+ cy.findByTestId("pinned-center-quadrant")
+ .findByRole("row")
+ .find("[data-column-id=ID]")
+ .findByTestId("cell-data")
+ .should("have.text", "1");
+
+ H.tableHeaderClick("ID");
+
+ cy.findByTestId("pinned-center-quadrant")
+ .findByRole("row")
+ .find("[data-column-id=ID]")
+ .findByTestId("cell-data")
+ .should("have.text", "2000");
+
+ H.tableHeaderClick("ID");
+
+ cy.findByTestId("pinned-center-quadrant")
+ .findByRole("row")
+ .find("[data-column-id=ID]")
+ .findByTestId("cell-data")
+ .should("have.text", "1");
+ });
+
it("should expand columns to the full width of the dashcard (metabase#57381)", () => {
const sideColumnsWidth = 200;
const expandedSideColumnsWidth = 2 * sideColumnsWidth;
diff --git a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/EditTableDataGrid.tsx b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/EditTableDataGrid.tsx
index e597c656136..a57685241cf 100644
--- a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/EditTableDataGrid.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/EditTableDataGrid.tsx
@@ -106,7 +106,6 @@ export const EditTableDataGrid = ({
columnsOptions,
columnOrder,
columnSizingMap,
- columnPinning: { left: [ROW_SELECT_COLUMN_ID] },
enableRowSelection: true,
rowSelection,
onRowSelectionChange,
diff --git a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/use-table-column-row-select.tsx b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/use-table-column-row-select.tsx
index 4b3160d209c..5b61510bbe4 100644
--- a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/use-table-column-row-select.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/data-grid/use-table-column-row-select.tsx
@@ -30,6 +30,7 @@ export function getRowSelectColumn({
id: ROW_SELECT_COLUMN_ID,
name: "",
accessorFn: () => null,
+ meta: { isUtilityColumn: true },
header: ({ table }: { table: Table<RowValues> }) => (
<Flex p="0.75rem" h="100%" align="center" className={S.tableHeaderCell}>
<Checkbox
diff --git a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.module.css b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.module.css
index 879e447155f..01c87562b97 100644
--- a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.module.css
+++ b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.module.css
@@ -6,31 +6,74 @@
font-size: 12.5px;
display: flex;
flex-direction: column;
+ min-height: 0;
}
.tableGrid {
- display: grid;
+ display: flex;
+ flex-flow: column nowrap;
+ outline: none;
+ overflow: auto;
flex-grow: 1;
- grid-template-rows: 36px;
width: 100%;
height: 100%;
- overflow: auto;
+ min-height: 0;
scrollbar-gutter: stable;
}
+.pinnedColumnsSection {
+ flex-shrink: 0;
+ position: sticky;
+ left: 0;
+ z-index: 2;
+}
+
.headerContainer {
+ display: flex;
+ flex-direction: row;
position: sticky;
- display: grid;
top: 0;
- z-index: 2;
+ z-index: 3;
border-bottom: 1px solid var(--mb-color-border-subtle);
+ min-width: max-content;
height: 37px;
}
-.bodyContainer {
- display: grid;
+.pinnedRowsSection {
+ position: sticky;
+ z-index: 3;
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+
+ /*
+ Since each cell already has border-bottom: 1px,
+ the total horizontal separator is now 2px + 1px = 3px,
+ matching the .pinnedColumnsSection.withSeparator at 3px.
+ */
+ border-bottom: 2px solid var(--mb-color-border-subtle);
+}
+
+.pinnedColumnsSection.withSeparator {
+ border-right: 3px solid var(--mb-color-border-subtle);
+}
+
+.centerRowsSection {
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+}
+
+.centerColumnsSection {
position: relative;
- outline: none;
+ flex: 0 0 auto;
+ min-width: 0;
+}
+
+.bodyContainer {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
}
.selectableBody {
@@ -40,6 +83,7 @@
.row {
display: flex;
width: 100%;
+ position: relative;
&.active {
background-color: color-mix(
diff --git a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.stories.tsx b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.stories.tsx
index 4ca0f5f4b7a..35cbdfd9e6b 100644
--- a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.stories.tsx
+++ b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.stories.tsx
@@ -342,14 +342,8 @@ export const SelectableRows: Story = () => {
[],
);
- const tableProps = useDataGridInstance({
- data: sampleData,
- columnsOptions: columns,
- columnPinning: { left: ["row_selection"] },
- enableRowSelection: true,
- rowSelection,
- onRowSelectionChange: setRowSelection,
- columnRowSelectOptions: {
+ const columnRowSelectOptions = useMemo<ColumnOptions<SampleDataType>>(
+ () => ({
id: "row_selection",
name: "Row Selection",
accessorFn: (row) => row.id,
@@ -375,7 +369,17 @@ export const SelectableRows: Story = () => {
</Flex>
</BaseCell>
),
- },
+ }),
+ [],
+ );
+
+ const tableProps = useDataGridInstance({
+ data: sampleData,
+ columnsOptions: columns,
+ enableRowSelection: true,
+ rowSelection,
+ onRowSelectionChange: setRowSelection,
+ columnRowSelectOptions,
});
return <DataGrid {...tableProps} />;
diff --git a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.tsx b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.tsx
index 8073a77bbd2..c8dbafc7ff0 100644
--- a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.tsx
+++ b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.tsx
@@ -1,51 +1,38 @@
-import { DndContext, pointerWithin } from "@dnd-kit/core";
-import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
+import { DndContext } from "@dnd-kit/core";
import {
SortableContext,
horizontalListSortingStrategy,
} from "@dnd-kit/sortable";
-import { flexRender } from "@tanstack/react-table";
+import type { HeaderGroup } from "@tanstack/react-table";
import cx from "classnames";
import type React from "react";
-import { useCallback, useEffect, useMemo } from "react";
+import { useCallback, useEffect, useState } from "react";
import _ from "underscore";
import { useForceUpdate } from "metabase/common/hooks/use-force-update";
-import { hasModifierKeys } from "metabase/common/utils/keyboard";
-import { AddColumnButton } from "metabase/data-grid/components/AddColumnButton/AddColumnButton";
-import { SortableHeader } from "metabase/data-grid/components/SortableHeader/SortableHeader";
+import { getScrollBarSize } from "metabase/lib/dom";
+
import {
ADD_COLUMN_BUTTON_WIDTH,
DEFAULT_FONT_SIZE,
HEADER_HEIGHT,
- PINNED_COLUMN_Z_INDEX,
-} from "metabase/data-grid/constants";
-import { isVirtualRow } from "metabase/data-grid/guards";
-import { DataGridThemeProvider } from "metabase/data-grid/hooks/use-table-theme";
-import type { DataGridInstance, DataGridTheme } from "metabase/data-grid/types";
-import { getScrollBarSize } from "metabase/lib/dom";
-
+ PINNED_BORDER_SEPARATOR_WIDTH,
+} from "../../constants";
+import { DataGridThemeProvider } from "../../hooks";
+import { useDataGridColumnsReordering } from "../../hooks/use-data-grid-columns-reordering";
+import type {
+ DataGridColumnType,
+ DataGridInstance,
+ DataGridRowType,
+ DataGridTheme,
+} from "../../types";
+import { AddColumnButton } from "../AddColumnButton/AddColumnButton";
+import { DataGridHeader } from "../DataGridHeader/DataGridHeader";
+import { DataGridRow } from "../DataGridRow/DataGridRow";
import { Footer } from "../Footer/Footer";
import S from "./DataGrid.module.css";
-
-// Component supports Mantine-like Styles API
-// Technically this is not the 1:1 mapping of the Mantine API, but it's close enough
-// https://mantine.dev/styles/styles-api/
-export type DataGridStylesNames =
- | "root"
- | "tableGrid"
- | "row"
- | "headerContainer"
- | "headerCell"
- | "bodyContainer"
- | "bodyCell"
- | "footer";
-
-export type DataGridStylesProps = {
- classNames?: { [key in DataGridStylesNames]?: string };
- styles?: { [key in DataGridStylesNames]?: React.CSSProperties };
-};
+import type { DataGridStylesProps } from "./types";
export interface DataGridProps<TData>
extends DataGridInstance<TData>,
@@ -66,47 +53,34 @@ export const DataGrid = function DataGrid<TData>({
measureRoot,
columnsReordering,
selection,
- emptyState,
theme,
classNames,
styles,
enablePagination,
showRowsCount,
+ getPinnedRows,
+ getCenterRows,
+ getPinnedColumns,
+ getCenterColumns,
getTotalHeight,
- getVisibleRows,
- isColumnReorderingDisabled,
+ datasetIndexAttributeName,
+ rowMeasureRef,
+ emptyState,
zoomedRowIndex,
onBodyCellClick,
- onHeaderCellClick,
- onAddColumnClick,
onWheel,
tableFooterExtraButtons,
rowsTruncated,
- sorting,
+ onAddColumnClick,
+ onHeaderCellClick,
+ isColumnReorderingDisabled,
}: DataGridProps<TData>) {
- const {
- virtualColumns,
- virtualPaddingLeft,
- virtualPaddingRight,
- rowVirtualizer,
- } = virtualGrid;
-
- const dndContextProps = useMemo(
- () => ({
- collisionDetection: pointerWithin,
- modifiers: [restrictToHorizontalAxis],
- ...columnsReordering,
- }),
- [columnsReordering],
- );
+ const { columnVirtualizer, virtualIndexAttributeName } = virtualGrid;
- const rowMeasureRef = useCallback(
- (element: HTMLElement | null) => {
- rowVirtualizer.measureElement(element);
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps -- `sorting` triggers re-measurement when sorting changes
- [rowVirtualizer, sorting],
- );
+ const [headerHeight, setHeaderHeight] = useState(HEADER_HEIGHT);
+ const headerRef = useCallback((node: HTMLDivElement | null) => {
+ setHeaderHeight(node?.offsetHeight ?? HEADER_HEIGHT);
+ }, []);
const forceUpdate = useForceUpdate();
useEffect(() => {
@@ -115,32 +89,11 @@ export const DataGrid = function DataGrid<TData>({
return () => window.removeEventListener("resize", handleResize);
}, [forceUpdate]);
+ const hasAddColumnButton = onAddColumnClick != null;
const isAddColumnButtonSticky =
+ hasAddColumnButton &&
table.getTotalSize() >=
- (gridRef.current?.offsetWidth ?? Infinity) - ADD_COLUMN_BUTTON_WIDTH;
-
- const addColumnMarginRight =
- getTotalHeight() >= (gridRef.current?.offsetHeight ?? Infinity)
- ? getScrollBarSize()
- : 0;
-
- const hasAddColumnButton = onAddColumnClick != null;
- const addColumnButton = useMemo(
- () =>
- hasAddColumnButton ? (
- <AddColumnButton
- marginRight={addColumnMarginRight}
- isSticky={isAddColumnButtonSticky}
- onClick={onAddColumnClick}
- />
- ) : null,
- [
- hasAddColumnButton,
- isAddColumnButtonSticky,
- onAddColumnClick,
- addColumnMarginRight,
- ],
- );
+ (gridRef.current?.offsetWidth ?? Infinity) - ADD_COLUMN_BUTTON_WIDTH;
const rowsCount = table.getRowModel().rows.length;
const backgroundColor =
@@ -151,9 +104,130 @@ export const DataGrid = function DataGrid<TData>({
? "var(--mb-color-background-primary)"
: backgroundColor);
+ const centerRows = getCenterRows();
+ const pinnedRows = getPinnedRows();
+ const pinnedColumns = getPinnedColumns();
+ const centerColumns = getCenterColumns();
+ const lastPinnedColumn = pinnedColumns.at(-1);
+ const isLastPinnedColumnSpecial =
+ lastPinnedColumn?.origin.columnDef.meta?.isUtilityColumn === true;
+ const hasSeparator = lastPinnedColumn != null && !isLastPinnedColumnSpecial;
+
+ const dndContextProps = useDataGridColumnsReordering(
+ columnsReordering,
+ pinnedColumns,
+ );
+
+ const pinnedColumnsWidth = table.getLeftTotalSize();
+ const pinnedPanelWidth = hasSeparator
+ ? pinnedColumnsWidth + PINNED_BORDER_SEPARATOR_WIDTH
+ : pinnedColumnsWidth;
+
+ const totalHeight = getTotalHeight();
+
+ const addColumnMarginRight =
+ totalHeight >= (gridRef.current?.offsetHeight ?? Infinity)
+ ? getScrollBarSize()
+ : 0;
+
+ const renderRow = (
+ row: DataGridRowType<TData>,
+ columns: DataGridColumnType<TData>[],
+ index: number,
+ measureRef?: (element: Element | null) => void,
+ ) => (
+ <DataGridRow
+ key={index}
+ row={row}
+ rowMeasureRef={measureRef}
+ pinnedRowsCount={pinnedRows.length}
+ columns={columns}
+ datasetIndexAttributeName={datasetIndexAttributeName}
+ virtualIndexAttributeName={virtualIndexAttributeName}
+ zoomedRowIndex={zoomedRowIndex}
+ selection={selection}
+ onBodyCellClick={onBodyCellClick}
+ classNames={classNames}
+ styles={styles}
+ />
+ );
+
+ const renderHeader = (
+ headerGroup: HeaderGroup<TData>,
+ columns: DataGridColumnType<TData>[],
+ ) => (
+ <DataGridHeader
+ headerGroup={headerGroup}
+ columns={columns}
+ backgroundColor={backgroundColor}
+ onHeaderCellClick={onHeaderCellClick}
+ isColumnReorderingDisabled={isColumnReorderingDisabled}
+ styles={styles}
+ />
+ );
+
+ const renderGridPanels = ({
+ pinnedContent,
+ centerContent,
+ rowsSection,
+ minHeight,
+ }: {
+ pinnedContent: React.ReactNode;
+ centerContent: React.ReactNode;
+ rowsSection: "pinned" | "center" | "header";
+ minHeight?: string;
+ }) => (
+ <>
+ {pinnedColumns.length > 0 && (
+ <div
+ className={cx(S.pinnedColumnsSection, {
+ [S.withSeparator]: hasSeparator,
+ })}
+ data-testid={`${rowsSection}-pinned-quadrant`}
+ style={{
+ width: pinnedPanelWidth,
+ minHeight,
+ backgroundColor: stickyElementsBackgroundColor,
+ }}
+ >
+ {pinnedContent}
+ </div>
+ )}
+ <div
+ className={S.centerColumnsSection}
+ data-testid={`${rowsSection}-center-quadrant`}
+ style={{
+ minHeight,
+ width: `${columnVirtualizer.getTotalSize()}px`,
+ backgroundColor,
+ }}
+ >
+ {centerContent}
+ </div>
+ </>
+ );
+
+ const renderBodyGridPanels = (
+ rows: DataGridRowType<TData>[],
+ rowsSection: "pinned" | "center" | "header",
+ measureRef?: (element: Element | null) => void,
+ minHeight?: string,
+ ) =>
+ renderGridPanels({
+ pinnedContent: rows.map((row, index) =>
+ renderRow(row, pinnedColumns, index),
+ ),
+ centerContent: rows.map((row, index) =>
+ renderRow(row, centerColumns, index, measureRef),
+ ),
+ minHeight,
+ rowsSection,
+ });
+
return (
<DataGridThemeProvider theme={theme}>
<DndContext {...dndContextProps}>
+ {measureRoot}
<div
className={cx(S.table, classNames?.root)}
data-testid="table-root"
@@ -165,11 +239,13 @@ export const DataGrid = function DataGrid<TData>({
}}
>
<div
+ ref={gridRef}
data-testid="table-scroll-container"
className={cx(S.tableGrid, classNames?.tableGrid)}
role="grid"
- ref={gridRef}
style={{
+ backgroundColor,
+ color: theme?.cell?.textColor,
paddingRight:
hasAddColumnButton && isAddColumnButtonSticky
? `${ADD_COLUMN_BUTTON_WIDTH}px`
@@ -179,6 +255,7 @@ export const DataGrid = function DataGrid<TData>({
onWheel={onWheel}
>
<div
+ ref={headerRef}
data-testid="table-header"
className={cx(S.headerContainer, classNames?.headerContainer)}
style={{
@@ -187,219 +264,67 @@ export const DataGrid = function DataGrid<TData>({
}}
>
{table.getHeaderGroups().map((headerGroup) => (
- <div
+ <SortableContext
key={headerGroup.id}
- className={cx(S.row, classNames?.row)}
- style={{
- height: `${HEADER_HEIGHT}px`,
- backgroundColor,
- ...styles?.row,
- }}
+ items={table.getState().columnOrder}
+ strategy={horizontalListSortingStrategy}
>
- {virtualPaddingLeft ? (
- <div style={{ width: virtualPaddingLeft }} />
- ) : null}
- <SortableContext
- items={table.getState().columnOrder}
- strategy={horizontalListSortingStrategy}
- >
- {virtualColumns.map((virtualColumn) => {
- const header = headerGroup.headers[virtualColumn.index];
- const headerCell = flexRender(
- header.column.columnDef.header,
- header.getContext(),
- );
- const width = header.column.getSize();
- const isPinned = header.column.getIsPinned();
- const style: React.CSSProperties = isPinned
- ? {
- width,
- position: "sticky",
- left: `${virtualColumn.start}px`,
- zIndex: PINNED_COLUMN_Z_INDEX,
- backgroundColor: stickyElementsBackgroundColor,
- }
- : {
- width,
- };
-
- const headerContent = isPinned ? (
- headerCell
- ) : (
- <SortableHeader
- className={cx(S.headerCell, classNames?.headerCell)}
- style={{
- backgroundColor: stickyElementsBackgroundColor,
- ...styles?.headerCell,
- }}
- isColumnReorderingDisabled={
- isColumnReorderingDisabled
- }
- header={header}
- onClick={onHeaderCellClick}
- >
- {headerCell}
- </SortableHeader>
- );
-
- return (
- <div
- key={header.id}
- style={style}
- data-header-id={header.id}
- >
- {headerContent}
- </div>
- );
- })}
- </SortableContext>
- {!isAddColumnButtonSticky ? addColumnButton : null}
- {virtualPaddingRight ? (
- <div style={{ width: virtualPaddingRight }} />
- ) : null}
- </div>
+ {renderGridPanels({
+ pinnedContent: renderHeader(headerGroup, pinnedColumns),
+ centerContent: renderHeader(headerGroup, centerColumns),
+ rowsSection: "header",
+ })}
+ </SortableContext>
))}
+ {hasAddColumnButton && !isAddColumnButtonSticky && (
+ <AddColumnButton onClick={onAddColumnClick} />
+ )}
</div>
- {rowsCount === 0 && emptyState}
-
- <div
- data-testid="table-body"
- className={cx(S.bodyContainer, classNames?.bodyContainer, {
- [S.selectableBody]: selection.isEnabled,
- })}
- style={{
- display: "grid",
- position: "relative",
- height: `${getTotalHeight()}px`,
- backgroundColor: theme?.cell?.backgroundColor,
- color: theme?.cell?.textColor,
- ...styles?.bodyContainer,
- }}
- >
- {getVisibleRows().map((maybeVirtualRow) => {
- const { row, virtualRow } = isVirtualRow(maybeVirtualRow)
- ? maybeVirtualRow
- : { row: maybeVirtualRow, virtualRow: undefined };
-
- const virtualRowStyles: React.CSSProperties =
- virtualRow != null
- ? {
- position: "absolute",
- minHeight: `${virtualRow.size}px`,
- transform: `translateY(${virtualRow.start}px)`,
- }
- : {};
-
- const dataIndex =
- virtualRow != null ? virtualRow.index : row.index;
- const active = zoomedRowIndex === dataIndex;
-
- return (
+ {rowsCount === 0 ? (
+ emptyState
+ ) : (
+ <div
+ data-testid="table-body"
+ className={cx(
+ S.bodyContainer,
+ {
+ [S.selectableBody]: selection.isEnabled,
+ },
+ classNames?.bodyContainer,
+ )}
+ style={styles?.bodyContainer}
+ >
+ {pinnedRows.length > 0 && (
<div
- role="row"
- key={row.id}
- ref={rowMeasureRef}
- data-dataset-index={row.index}
- data-index={dataIndex}
- data-allow-page-break-after="true"
- data-row-selected={row.getIsSelected()}
- className={cx(S.row, classNames?.row, {
- [S.active]: active,
- })}
+ className={S.pinnedRowsSection}
style={{
- ...virtualRowStyles,
- ...styles?.row,
+ backgroundColor: stickyElementsBackgroundColor,
+ top: `${headerHeight}px`,
}}
>
- {virtualPaddingLeft ? (
- <div
- className={cx(S.bodyCell, classNames?.bodyCell)}
- style={{
- width: virtualPaddingLeft,
- ...styles?.bodyCell,
- }}
- />
- ) : null}
-
- {virtualColumns.map((virtualColumn) => {
- const cell = row.getVisibleCells()[virtualColumn.index];
- const isPinned = cell.column.getIsPinned();
- const width = cell.column.getSize();
- const columnDef = cell.column.columnDef;
- const isSelectable =
- selection.isEnabled && columnDef?.meta?.enableSelection;
-
- const style: React.CSSProperties = isPinned
- ? {
- width,
- position: "sticky",
- left: `${virtualColumn.start}px`,
- zIndex: PINNED_COLUMN_Z_INDEX,
- backgroundColor: active
- ? undefined
- : stickyElementsBackgroundColor,
- ...styles?.bodyCell,
- }
- : {
- width,
- ...styles?.bodyCell,
- };
- return (
- <div
- key={cell.id}
- aria-selected={selection.isCellSelected(cell)}
- data-column-id={cell.column.id}
- data-selectable-cell={isSelectable ? "" : undefined}
- className={cx(S.bodyCell, classNames?.bodyCell, {
- [S.focusedCell]: selection.isCellFocused(cell),
- })}
- onClick={(e) => {
- if (hasModifierKeys(e)) {
- return;
- }
- onBodyCellClick?.(
- e,
- cell.row.index,
- cell.column.id,
- );
- }}
- onDoubleClick={() =>
- selection.handlers.handleCellDoubleClick(cell)
- }
- onMouseDown={(e) =>
- selection.handlers.handleCellMouseDown(e, cell)
- }
- onMouseUp={(e) =>
- selection.handlers.handleCellMouseUp(e, cell)
- }
- onMouseOver={(e) =>
- selection.handlers.handleCellMouseOver(e, cell)
- }
- style={style}
- >
- {flexRender(cell.column.columnDef.cell, {
- ...cell.getContext(),
- isSelected: selection.isCellSelected(cell),
- })}
- </div>
- );
- })}
- {virtualPaddingRight ? (
- <div
- className={cx(S.bodyCell, classNames?.bodyCell)}
- style={{
- width: virtualPaddingRight,
- ...styles?.bodyCell,
- }}
- />
- ) : null}
+ {renderBodyGridPanels(pinnedRows, "pinned")}
</div>
- );
- })}
- </div>
+ )}
+ <div className={S.centerRowsSection}>
+ {renderBodyGridPanels(
+ centerRows,
+ "center",
+ rowMeasureRef,
+ `${totalHeight}px`,
+ )}
+ </div>
+ </div>
+ )}
</div>
- {isAddColumnButtonSticky ? addColumnButton : null}
+ {isAddColumnButtonSticky && (
+ <AddColumnButton
+ isSticky
+ marginRight={addColumnMarginRight}
+ onClick={onAddColumnClick}
+ />
+ )}
+
<Footer
table={table}
enablePagination={enablePagination}
@@ -410,7 +335,6 @@ export const DataGrid = function DataGrid<TData>({
tableFooterExtraButtons={tableFooterExtraButtons}
/>
</div>
- {measureRoot}
</DndContext>
</DataGridThemeProvider>
);
diff --git a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.unit.spec.tsx b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.unit.spec.tsx
index 300dda53c30..2d70d12cbd7 100644
--- a/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.unit.spec.tsx
+++ b/frontend/src/metabase/data-grid/components/DataGrid/DataGrid.unit.spec.tsx
@@ -6,7 +6,6 @@ import {
mockGetBoundingClientRect,
renderWithProviders,
screen,
- within,
} from "__support__/ui";
import {
type ColumnOptions,
@@ -54,6 +53,8 @@ interface TestDataGridProps {
sortableColumns?: boolean;
wrapableColumns?: string[];
enableSelection?: boolean;
+ pinnedTopRowsCount?: number;
+ pinnedLeftColumnsCount?: number;
}
const TestDataGrid = ({
@@ -68,6 +69,8 @@ const TestDataGrid = ({
sortableColumns = false,
wrapableColumns = [],
enableSelection = false,
+ pinnedTopRowsCount,
+ pinnedLeftColumnsCount,
}: TestDataGridProps) => {
const columns: ColumnOptions<SampleDataType>[] = useMemo(
() => [
@@ -138,6 +141,8 @@ const TestDataGrid = ({
onColumnResize,
rowId,
enableSelection,
+ pinnedTopRowsCount,
+ pinnedLeftColumnsCount,
});
return (
@@ -226,18 +231,14 @@ describe("DataGrid", () => {
jest.runAllTimers();
});
- const rows = screen.getAllByRole("row").slice(1); // Skip header row
+ const body = screen.getByTestId("table-body");
+ const rowIdCells = body.querySelectorAll('[data-testid="row-id-cell"]');
- expect(rows.length).toBeGreaterThan(0);
+ expect(rowIdCells).toHaveLength(sampleData.length);
- rows.forEach((row, index) => {
- const cells = within(row).getAllByRole("gridcell");
- expect(cells[0]).toHaveTextContent(String(index + 2));
+ rowIdCells.forEach((cell, index) => {
+ expect(cell).toHaveTextContent(String(index + 1));
});
-
- const firstRow = rows[0];
- const cellsInRow = within(firstRow).getAllByRole("gridcell");
- expect(cellsInRow.length).toBe(4); // 3 data columns + 1 row ID column
});
it("displays proper sort indicators for sortable columns", () => {
@@ -267,6 +268,127 @@ describe("DataGrid", () => {
expect(nameSortIcon).toBeDefined();
});
+ it("renders pinned rows in a separate sticky section", () => {
+ const pinnedTopRowsCount = 2;
+ renderWithProviders(
+ <TestDataGrid pinnedTopRowsCount={pinnedTopRowsCount} />,
+ );
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const pinnedPinnedQuadrant = screen.queryByTestId("pinned-pinned-quadrant");
+ expect(pinnedPinnedQuadrant).not.toBeInTheDocument();
+
+ const pinnedCenterQuadrant = screen.getByTestId("pinned-center-quadrant");
+ const pinnedRows = pinnedCenterQuadrant.querySelectorAll('[role="row"]');
+ expect(pinnedRows).toHaveLength(pinnedTopRowsCount);
+
+ const centerCenterQuadrant = screen.getByTestId("center-center-quadrant");
+ const centerRows = centerCenterQuadrant.querySelectorAll('[role="row"]');
+ expect(centerRows).toHaveLength(sampleData.length - pinnedTopRowsCount);
+ });
+
+ it("renders pinned columns in a separate sticky section", () => {
+ renderWithProviders(<TestDataGrid pinnedLeftColumnsCount={1} />);
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const headerPinnedQuadrant = screen.getByTestId("header-pinned-quadrant");
+ const pinnedHeaderCells = headerPinnedQuadrant.querySelectorAll(
+ '[data-testid="header-cell"]',
+ );
+ expect(pinnedHeaderCells).toHaveLength(1);
+ expect(pinnedHeaderCells[0]).toHaveTextContent("ID");
+
+ const headerCenterQuadrant = screen.getByTestId("header-center-quadrant");
+ const centerHeaderCells = headerCenterQuadrant.querySelectorAll(
+ '[data-testid="header-cell"]',
+ );
+ expect(centerHeaderCells).toHaveLength(3);
+
+ const centerPinnedQuadrant = screen.getByTestId("center-pinned-quadrant");
+ const pinnedBodyCells =
+ centerPinnedQuadrant.querySelectorAll('[role="gridcell"]');
+ expect(pinnedBodyCells.length).toBeGreaterThan(0);
+ });
+
+ it("renders both pinned rows and pinned columns together", () => {
+ renderWithProviders(
+ <TestDataGrid pinnedTopRowsCount={1} pinnedLeftColumnsCount={1} />,
+ );
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const pinnedPinnedQuadrant = screen.getByTestId("pinned-pinned-quadrant");
+ const pinnedPinnedCells =
+ pinnedPinnedQuadrant.querySelectorAll('[role="gridcell"]');
+ expect(pinnedPinnedCells).toHaveLength(1);
+
+ const pinnedCenterQuadrant = screen.getByTestId("pinned-center-quadrant");
+ const pinnedCenterCells =
+ pinnedCenterQuadrant.querySelectorAll('[role="gridcell"]');
+ expect(pinnedCenterCells).toHaveLength(3);
+
+ const centerPinnedQuadrant = screen.getByTestId("center-pinned-quadrant");
+ const centerPinnedRows =
+ centerPinnedQuadrant.querySelectorAll('[role="row"]');
+ expect(centerPinnedRows).toHaveLength(sampleData.length - 1);
+
+ const centerCenterQuadrant = screen.getByTestId("center-center-quadrant");
+ const centerCenterRows =
+ centerCenterQuadrant.querySelectorAll('[role="row"]');
+ expect(centerCenterRows).toHaveLength(sampleData.length - 1);
+ });
+
+ it("unpins columns that exceed 90% of container width", () => {
+ renderWithProviders(<TestDataGrid pinnedLeftColumnsCount={2} />);
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const headerPinnedQuadrant = screen.getByTestId("header-pinned-quadrant");
+ const pinnedHeaderCells = headerPinnedQuadrant.querySelectorAll(
+ '[data-testid="header-cell"]',
+ );
+ expect(pinnedHeaderCells).toHaveLength(1);
+ expect(pinnedHeaderCells[0]).toHaveTextContent("ID");
+ });
+
+ it("unpins rows that exceed 80% of container height", () => {
+ renderWithProviders(<TestDataGrid pinnedTopRowsCount={5} />);
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const pinnedCenterQuadrant = screen.getByTestId("pinned-center-quadrant");
+ const pinnedRows = pinnedCenterQuadrant.querySelectorAll('[role="row"]');
+ expect(pinnedRows.length).toBeLessThan(5);
+ expect(pinnedRows.length).toBe(3);
+
+ const centerCenterQuadrant = screen.getByTestId("center-center-quadrant");
+ const centerRows = centerCenterQuadrant.querySelectorAll('[role="row"]');
+ expect(centerRows).toHaveLength(sampleData.length - 3);
+ });
+
+ it("renders center section rows when all columns are pinned", () => {
+ renderWithProviders(<TestDataGrid pinnedLeftColumnsCount={4} />);
+ act(() => {
+ jest.runAllTimers();
+ });
+
+ const centerCenterQuadrant = screen.getByTestId("center-center-quadrant");
+ const centerRows = centerCenterQuadrant.querySelectorAll('[role="row"]');
+
+ expect(centerRows.length).toBeGreaterThan(0);
+
+ centerRows.forEach((row) => {
+ expect(row).toHaveAttribute("data-index");
+ });
+ });
+
it("can copy selected cells with headers included", async () => {
const writeTextMock = jest.fn().mockResolvedValue(undefined);
Object.assign(navigator, {
diff --git a/frontend/src/metabase/data-grid/components/DataGrid/types.ts b/frontend/src/metabase/data-grid/components/DataGrid/types.ts
new file mode 100644
index 00000000000..d7ea1cf42a1
--- /dev/null
+++ b/frontend/src/metabase/data-grid/components/DataGrid/types.ts
@@ -0,0 +1,19 @@
+// Component supports Mantine-like Styles API
+// Technically this is not the 1:1 mapping of the Mantine API, but it's close enough
+// https://mantine.dev/styles/styles-api/
+import type React from "react";
+
+export type DataGridStylesNames =
+ | "root"
+ | "tableGrid"
+ | "row"
+ | "headerContainer"
+ | "headerCell"
+ | "bodyContainer"
+ | "bodyCell"
+ | "footer";
+
+export type DataGridStylesProps = {
+ classNames?: { [key in DataGridStylesNames]?: string };
+ styles?: { [key in DataGridStylesNames]?: React.CSSProperties };
+};
diff --git a/frontend/src/metabase/data-grid/components/DataGridHeader/DataGridHeader.tsx b/frontend/src/metabase/data-grid/components/DataGridHeader/DataGridHeader.tsx
new file mode 100644
index 00000000000..19b6abc1b79
--- /dev/null
+++ b/frontend/src/metabase/data-grid/components/DataGridHeader/DataGridHeader.tsx
@@ -0,0 +1,81 @@
+import { type HeaderGroup, flexRender } from "@tanstack/react-table";
+import cx from "classnames";
+import type React from "react";
+
+import { HEADER_BASE_HEIGHT } from "metabase/data-grid/constants";
+import { getColumnPositionStyles } from "metabase/data-grid/utils/stylings";
+
+import type { DataGridColumnType } from "../../types";
+import S from "../DataGrid/DataGrid.module.css";
+import type { DataGridStylesProps } from "../DataGrid/types";
+import { SortableHeader } from "../SortableHeader/SortableHeader";
+
+export interface DataGridHeaderProps<TData> extends DataGridStylesProps {
+ headerGroup: HeaderGroup<TData>;
+ columns: DataGridColumnType<TData>[];
+ backgroundColor?: string;
+ isColumnReorderingDisabled?: boolean;
+ onHeaderCellClick?: (
+ event: React.MouseEvent<HTMLDivElement>,
+ columnId?: string,
+ ) => void;
+}
+
+export const DataGridHeader = <TData,>({
+ headerGroup,
+ columns,
+ backgroundColor,
+ isColumnReorderingDisabled,
+ onHeaderCellClick,
+ classNames,
+ styles,
+}: DataGridHeaderProps<TData>) => {
+ const paddingLeft = columns[0]?.virtualItem?.start ?? 0;
+
+ return (
+ <div
+ className={cx(S.row, classNames?.row)}
+ style={{
+ backgroundColor,
+ paddingLeft,
+ height: `${HEADER_BASE_HEIGHT}px`,
+ ...styles?.row,
+ }}
+ >
+ {columns.map((column) => {
+ const header = headerGroup.headers[column.origin.getIndex()];
+ const headerCell = flexRender(
+ header.column.columnDef.header,
+ header.getContext(),
+ );
+ const isUtilityColumn =
+ header.column.columnDef.meta?.isUtilityColumn === true;
+ const columnPositionStyles = getColumnPositionStyles(column);
+
+ const headerContent = isUtilityColumn ? (
+ headerCell
+ ) : (
+ <SortableHeader
+ className={cx(S.headerCell, classNames?.headerCell)}
+ style={styles?.headerCell}
+ isColumnReorderingDisabled={isColumnReorderingDisabled}
+ header={header}
+ onClick={onHeaderCellClick}
+ >
+ {headerCell}
+ </SortableHeader>
+ );
+
+ return (
+ <div
+ key={header.id}
+ style={columnPositionStyles}
+ data-header-id={header.id}
+ >
+ {headerContent}
+ </div>
+ );
+ })}
+ </div>
+ );
+};
diff --git a/frontend/src/metabase/data-grid/components/DataGridRow/DataGridRow.tsx b/frontend/src/metabase/data-grid/components/DataGridRow/DataGridRow.tsx
new file mode 100644
index 00000000000..1a2ce339a7b
--- /dev/null
+++ b/frontend/src/metabase/data-grid/components/DataGridRow/DataGridRow.tsx
@@ -0,0 +1,118 @@
+import { flexRender } from "@tanstack/react-table";
+import cx from "classnames";
+import type React from "react";
+
+import { hasModifierKeys } from "metabase/common/utils/keyboard";
+
+import type {
+ DataGridColumnType,
+ DataGridRowType,
+ DataGridSelection,
+} from "../../types";
+import {
+ getColumnPositionStyles,
+ getRowPositionStyles,
+} from "../../utils/stylings";
+import S from "../DataGrid/DataGrid.module.css";
+import type { DataGridStylesProps } from "../DataGrid/types";
+
+export interface DataGridRowProps<TData> extends DataGridStylesProps {
+ row: DataGridRowType<TData>;
+ columns: DataGridColumnType<TData>[];
+ rowMeasureRef?: ((element: Element | null) => void) | undefined;
+ zoomedRowIndex: number | undefined;
+ pinnedRowsCount: number;
+ selection: DataGridSelection;
+ datasetIndexAttributeName: string;
+ virtualIndexAttributeName: string;
+ onBodyCellClick?: (
+ event: React.MouseEvent<HTMLDivElement>,
+ rowIndex: number,
+ columnId: string,
+ ) => void;
+}
+
+export const DataGridRow = <TData,>({
+ row,
+ columns,
+ rowMeasureRef,
+ pinnedRowsCount,
+ zoomedRowIndex,
+ selection,
+ datasetIndexAttributeName,
+ virtualIndexAttributeName,
+ onBodyCellClick,
+ classNames,
+ styles,
+}: DataGridRowProps<TData>) => {
+ const rowPositionStyles = getRowPositionStyles(row);
+ const paddingLeft = columns[0]?.virtualItem?.start ?? 0;
+
+ /**
+ * we must render this div with a ref even if there are no columns.
+ * Otherwise, Tanstack's virtualizer won't be able to measure the row.
+ * As a result, row heights in the pinned and center column sections become unsynced.
+ * An alternative solution would be to create a custom ResizeObserver to track both parts of the row,
+ * but the current solution is sufficient for now.
+ *
+ * This is covered by test "renders center section rows when all columns are pinned"
+ */
+ return (
+ <div
+ role="row"
+ key={row.origin.id}
+ ref={rowMeasureRef}
+ {...{
+ [datasetIndexAttributeName]: row.origin.index,
+ [virtualIndexAttributeName]: row.virtualItem?.index,
+ }}
+ data-allow-page-break-after="true"
+ data-row-selected={row.origin.getIsSelected()}
+ className={cx(
+ S.row,
+ {
+ [S.withSeparator]: row.origin.index === pinnedRowsCount - 1,
+ [S.active]: zoomedRowIndex === row.origin.index,
+ },
+ classNames?.row,
+ )}
+ style={{ ...rowPositionStyles, paddingLeft, ...styles?.row }}
+ >
+ {columns.map((column) => {
+ const cell = column.getCell(row.origin);
+ const columnDef = column.origin.columnDef;
+ const isSelectable =
+ selection.isEnabled && columnDef?.meta?.enableSelection;
+
+ const columnPositionStyles = getColumnPositionStyles(column);
+ return (
+ <div
+ key={cell.id}
+ aria-selected={selection.isCellSelected(cell)}
+ data-column-id={column.origin.id}
+ data-selectable-cell={isSelectable ? "" : undefined}
+ className={cx(S.bodyCell, classNames?.bodyCell, {
+ [S.focusedCell]: selection.isCellFocused(cell),
+ })}
+ onClick={(e) => {
+ if (hasModifierKeys(e)) {
+ return;
+ }
+ onBodyCellClick?.(e, cell.row.index, column.origin.id);
+ }}
+ onDoubleClick={() => selection.handlers.handleCellDoubleClick(cell)}
+ onMouseDown={(e) => selection.handlers.handleCellMouseDown(e, cell)}
+ onMouseUp={(e) => selection.handlers.handleCellMouseUp(e, cell)}
+ onMouseOver={(e) => selection.handlers.handleCellMouseOver(e, cell)}
+ style={{ ...columnPositionStyles, ...styles?.bodyCell }}
+ >
+ {flexRender(columnDef.cell, {
+ ...cell.getContext(),
+ isSelected: selection.isCellSelected(cell),
+ })}
+ </div>
+ );
+ })}
+ </div>
+ );
+};
diff --git a/frontend/src/metabase/data-grid/components/SortableHeader/SortableHeader.tsx b/frontend/src/metabase/data-grid/components/SortableHeader/SortableHeader.tsx
index d60c53c5075..d6d7fdcb2a5 100644
--- a/frontend/src/metabase/data-grid/components/SortableHeader/SortableHeader.tsx
+++ b/frontend/src/metabase/data-grid/components/SortableHeader/SortableHeader.tsx
@@ -7,7 +7,7 @@ import { type CSSProperties, memo, useCallback, useMemo, useRef } from "react";
import S from "./SortableHeader.module.css";
-// if header is dragged fewer than than this number of pixels we consider it a click instead of a drag
+// if header is dragged fewer than this number of pixels we consider it a click instead of a drag
const HEADER_DRAG_THRESHOLD = 8;
type DragPosition = { x: number; y: number };
@@ -29,7 +29,6 @@ export const SortableHeader = memo(function SortableHeader<TData, TValue>({
style: styleProp,
onClick,
}: SortableHeaderProps<TData, TValue>) {
- const isPinned = header.column.getIsPinned();
const canResize = header.column.columnDef.enableResizing;
const headerClickTargetSelector =
header.column.columnDef.meta?.headerClickTargetSelector;
@@ -38,13 +37,13 @@ export const SortableHeader = memo(function SortableHeader<TData, TValue>({
const { attributes, isDragging, listeners, setNodeRef, transform } =
useSortable({
id,
- disabled: isColumnReorderingDisabled || !!isPinned,
+ disabled: isColumnReorderingDisabled,
});
const dragStartPosition = useRef<DragPosition | null>(null);
const rootStyle = useMemo<CSSProperties>(() => {
- if (isPinned) {
+ if (isColumnReorderingDisabled) {
return styleProp ?? {};
}
return {
@@ -57,10 +56,10 @@ export const SortableHeader = memo(function SortableHeader<TData, TValue>({
outline: "none",
...styleProp,
};
- }, [isDragging, transform, isPinned, styleProp]);
+ }, [isDragging, transform, isColumnReorderingDisabled, styleProp]);
const nodeAttributes = useMemo(() => {
- if (isPinned) {
+ if (isColumnReorderingDisabled) {
return {};
}
@@ -68,7 +67,7 @@ export const SortableHeader = memo(function SortableHeader<TData, TValue>({
...listeners,
...attributes,
};
- }, [attributes, isPinned, listeners]);
+ }, [attributes, isColumnReorderingDisabled, listeners]);
const handleDragStart = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
dragStartPosition.current = { x: e.clientX, y: e.clientY };
diff --git a/frontend/src/metabase/data-grid/constants.ts b/frontend/src/metabase/data-grid/constants.ts
index 0947b815e49..cb78e7bfd9c 100644
--- a/frontend/src/metabase/data-grid/constants.ts
+++ b/frontend/src/metabase/data-grid/constants.ts
@@ -1,9 +1,13 @@
export const ROW_HEIGHT = 36;
-export const HEADER_HEIGHT = 36;
+export const HEADER_BASE_HEIGHT = 36;
+export const HEADER_BORDER_SIZE = 1;
+export const HEADER_HEIGHT = HEADER_BASE_HEIGHT + HEADER_BORDER_SIZE;
export const ADD_COLUMN_BUTTON_WIDTH = 36;
export const MIN_COLUMN_WIDTH = 60;
export const ROW_ID_COLUMN_ID = `\0_INDEX`;
export const TRUNCATE_LONG_CELL_WIDTH = 780;
-export const PINNED_COLUMN_Z_INDEX = 1;
export const DEFAULT_FONT_SIZE = "12.5px";
export const FOOTER_HEIGHT = 30;
+export const PINNED_BORDER_SEPARATOR_WIDTH = 3;
+export const DATASET_INDEX_ATTRIBUTE_NAME = "data-dataset-index";
+export const VIRTUAL_INDEX_ATTRIBUTE_NAME = "data-index";
diff --git a/frontend/src/metabase/data-grid/guards.ts b/frontend/src/metabase/data-grid/guards.ts
deleted file mode 100644
index 0fd36b43a35..00000000000
--- a/frontend/src/metabase/data-grid/guards.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { MaybeVirtualRow, VirtualRow } from "./types";
-
-export const isVirtualRow = <TData>(
- maybeVirtualRow: MaybeVirtualRow<TData>,
-): maybeVirtualRow is VirtualRow<TData> => {
- return "virtualRow" in maybeVirtualRow;
-};
diff --git a/frontend/src/metabase/data-grid/hooks/use-cell-selection.tsx b/frontend/src/metabase/data-grid/hooks/use-cell-selection.tsx
index 242b83099a0..1e6e8b304c5 100644
--- a/frontend/src/metabase/data-grid/hooks/use-cell-selection.tsx
+++ b/frontend/src/metabase/data-grid/hooks/use-cell-selection.tsx
@@ -8,7 +8,7 @@ import {
} from "react";
import _ from "underscore";
-import type { CellId, DataGridSelection } from "../types";
+import type { CellId, DataGridSelection, ScrollToDestinations } from "../types";
import { formatCellValueForCopy } from "../utils/formatting";
const noopHandlers: DataGridSelection["handlers"] = {
@@ -31,13 +31,7 @@ interface UseCellSelectionProps {
/** Whether cell selection is enabled */
isEnabled?: boolean;
/** Optional function to scroll to a specific cell */
- scrollTo?: ({
- rowIndex,
- columnIndex,
- }: {
- rowIndex?: number;
- columnIndex?: number;
- }) => void;
+ scrollTo?: (destinations: ScrollToDestinations) => void;
/** Callback when selection changes */
onChangeSelection?: (cells: CellId[]) => void;
}
@@ -151,7 +145,7 @@ export const useCellSelection = ({
.find((c) => c.column.id === selectedCell.columnId);
if (previousRowCell && canSelectCell(previousRowCell)) {
const newSelection = [getCellSelectionData(previousRowCell)];
- scrollTo?.({ rowIndex: previousRowIndex });
+ scrollTo?.({ row: { index: previousRowIndex } });
return newSelection;
}
}, [getLastSelectedCell, table, scrollTo]);
@@ -168,7 +162,7 @@ export const useCellSelection = ({
.find((c) => c.column.id === selectedCell.columnId);
if (nextRowCell && canSelectCell(nextRowCell)) {
const newSelection = [getCellSelectionData(nextRowCell)];
- scrollTo?.({ rowIndex: nextRowIndex });
+ scrollTo?.({ row: { index: nextRowIndex } });
return newSelection;
}
}, [getLastSelectedCell, table, scrollTo]);
@@ -183,7 +177,7 @@ export const useCellSelection = ({
const previousCell = selectedCell.row.getAllCells()[previousColumnIndex];
if (previousCell && canSelectCell(previousCell)) {
const newSelection = [getCellSelectionData(previousCell)];
- scrollTo?.({ columnIndex: previousColumnIndex });
+ scrollTo?.({ column: { index: previousColumnIndex } });
return newSelection;
}
}, [getLastSelectedCell, scrollTo]);
@@ -198,7 +192,7 @@ export const useCellSelection = ({
const nextCell = selectedCell.row.getAllCells()[nextColumnIndex];
if (nextCell && canSelectCell(nextCell)) {
const newSelection = [getCellSelectionData(nextCell)];
- scrollTo?.({ columnIndex: nextColumnIndex });
+ scrollTo?.({ column: { index: nextColumnIndex } });
return newSelection;
}
}, [getLastSelectedCell, scrollTo]);
diff --git a/frontend/src/metabase/data-grid/hooks/use-column-pinning-by-count.ts b/frontend/src/metabase/data-grid/hooks/use-column-pinning-by-count.ts
new file mode 100644
index 00000000000..8471af44150
--- /dev/null
+++ b/frontend/src/metabase/data-grid/hooks/use-column-pinning-by-count.ts
@@ -0,0 +1,47 @@
+import type {
+ ColumnPinningState,
+ ColumnSizingState,
+} from "@tanstack/react-table";
+import { type RefObject, useMemo, useState } from "react";
+
+import { countWithinLimit } from "../utils/count-within-limit";
+
+type UseColumnPinningByCountProps = {
+ gridRef: RefObject<HTMLDivElement>;
+ pinnedColumnsCount: number;
+ columnSizingMap: ColumnSizingState;
+ columnOrder: string[];
+};
+
+export const useColumnPinningByCount = ({
+ gridRef,
+ pinnedColumnsCount,
+ columnOrder,
+ columnSizingMap,
+}: UseColumnPinningByCountProps) => {
+ const [isLimitBypassed, setIsLimitBypassed] = useState<boolean>(false);
+
+ const containerWidth =
+ gridRef.current?.getBoundingClientRect().width ?? window.innerWidth;
+
+ const columnPinning = useMemo<ColumnPinningState>(() => {
+ const candidateColumns = columnOrder.slice(0, pinnedColumnsCount);
+ if (isLimitBypassed) {
+ return { left: candidateColumns };
+ }
+ const maxWidth = containerWidth * 0.9;
+ const effectiveCount = countWithinLimit(
+ candidateColumns.map((id) => columnSizingMap[id] ?? 0),
+ maxWidth,
+ );
+ return { left: columnOrder.slice(0, effectiveCount) };
+ }, [
+ isLimitBypassed,
+ containerWidth,
+ pinnedColumnsCount,
+ columnOrder,
+ columnSizingMap,
+ ]);
+
+ return { columnPinning, toggle: setIsLimitBypassed };
+};
diff --git a/frontend/src/metabase/data-grid/hooks/use-columns-reordering.tsx b/frontend/src/metabase/data-grid/hooks/use-columns-reordering.tsx
index 0b2e42450a1..1aac34a9f94 100644
--- a/frontend/src/metabase/data-grid/hooks/use-columns-reordering.tsx
+++ b/frontend/src/metabase/data-grid/hooks/use-columns-reordering.tsx
@@ -16,8 +16,6 @@ import type { Table as ReactTable } from "@tanstack/react-table";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import _ from "underscore";
-import { ROW_ID_COLUMN_ID } from "../constants";
-
export type ColumnsReordering = {
sensors: SensorDescriptor<SensorOptions>[];
onDragOver: (event: DragOverEvent) => void;
@@ -108,7 +106,8 @@ export const useColumnsReordering = <TData,>(
const newColumnOrder = table.getState().columnOrder;
if (!_.isEqual(newColumnOrder, prevOrder.current)) {
const dataColumns = newColumnOrder.filter(
- (columnName) => columnName !== ROW_ID_COLUMN_ID,
+ (columnName) =>
+ table.getColumn(columnName)?.columnDef.meta?.isUtilityColumn !== true,
);
onColumnReorder?.(dataColumns);
}
diff --git a/frontend/src/metabase/data-grid/hooks/use-data-grid-columns-reordering.tsx b/frontend/src/metabase/data-grid/hooks/use-data-grid-columns-reordering.tsx
new file mode 100644
index 00000000000..2f7772973c3
--- /dev/null
+++ b/frontend/src/metabase/data-grid/hooks/use-data-grid-columns-reordering.tsx
@@ -0,0 +1,42 @@
+import { pointerWithin } from "@dnd-kit/core";
+import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
+import { useCallback, useMemo } from "react";
+
+import type { DataGridColumnType } from "../types";
+
+import type { ColumnsReordering } from "./use-columns-reordering";
+
+export const useDataGridColumnsReordering = <TData,>(
+ columnsReordering: ColumnsReordering,
+ pinnedColumns: DataGridColumnType<TData>[],
+) => {
+ const pinnedColumnIdSet = useMemo(
+ () => new Set(pinnedColumns.map((c) => c.origin.id)),
+ [pinnedColumns],
+ );
+
+ const collisionDetection = useCallback(
+ (args: Parameters<typeof pointerWithin>[0]) => {
+ const collisions = pointerWithin(args);
+ if (collisions.length <= 1) {
+ return collisions;
+ }
+
+ const pinnedCollisions = collisions.filter((c) =>
+ pinnedColumnIdSet.has(String(c.id)),
+ );
+
+ return pinnedCollisions.length > 0 ? pinnedCollisions : collisions;
+ },
+ [pinnedColumnIdSet],
+ );
+
+ return useMemo(
+ () => ({
+ collisionDetection,
+ modifiers: [restrictToHorizontalAxis],
+ ...columnsReordering,
+ }),
+ [collisionDetection, columnsReordering],
+ );
+};
diff --git a/frontend/src/metabase/data-grid/hooks/use-data-grid-instance.tsx b/frontend/src/metabase/data-grid/hooks/use-data-grid-instance.tsx
index 1b83426be5f..20daed1ef65 100644
--- a/frontend/src/metabase/data-grid/hooks/use-data-grid-instance.tsx
+++ b/frontend/src/metabase/data-grid/hooks/use-data-grid-instance.tsx
@@ -1,6 +1,7 @@
import {
type ColumnSizingState,
type PaginationState,
+ type Row,
getCoreRowModel,
getPaginationRowModel,
getSortedRowModel,
@@ -19,19 +20,25 @@ import { usePrevious, useUpdateEffect } from "react-use";
import _ from "underscore";
import {
+ DATASET_INDEX_ATTRIBUTE_NAME,
MIN_COLUMN_WIDTH,
- ROW_ID_COLUMN_ID,
+ ROW_HEIGHT,
TRUNCATE_LONG_CELL_WIDTH,
+ VIRTUAL_INDEX_ATTRIBUTE_NAME,
} from "metabase/data-grid/constants";
import { useBodyCellMeasure } from "metabase/data-grid/hooks/use-body-cell-measure";
import { useColumnResizeObserver } from "metabase/data-grid/hooks/use-column-resize-observer";
import { useColumnsReordering } from "metabase/data-grid/hooks/use-columns-reordering";
import { useMeasureColumnWidths } from "metabase/data-grid/hooks/use-measure-column-widths";
+import { useRowSizing } from "metabase/data-grid/hooks/use-row-sizing";
import { useVirtualGrid } from "metabase/data-grid/hooks/use-virtual-grid";
import type {
+ DataGridColumnType,
DataGridInstance,
DataGridOptions,
+ DataGridRowType,
ExpandedColumnsState,
+ ScrollToDestinations,
} from "metabase/data-grid/types";
import { getDataColumn } from "metabase/data-grid/utils/columns/data-column";
import { getRowIdColumn } from "metabase/data-grid/utils/columns/row-id-column";
@@ -42,16 +49,17 @@ import { getTruncatedColumnSizing } from "../utils/column-sizing";
import { maybeExpandColumnWidths } from "../utils/maybe-expand-column-widths";
import { useCellSelection } from "./use-cell-selection";
+import { useColumnPinningByCount } from "./use-column-pinning-by-count";
import { useExpandColumnsToMinGridWidth } from "./use-expand-columns-to-min-grid-width";
+import { useRowPinningByCount } from "./use-row-pinning-by-count";
// Disable pagination by setting pageSize to -1
const DISABLED_PAGINATION_STATE = { pageSize: -1, pageIndex: 0 };
-// Creates a column order array with row ID column first if present
-const getColumnOrder = (dataColumnsOrder: string[], hasRowIdColumn: boolean) =>
- _.uniq(
- hasRowIdColumn ? [ROW_ID_COLUMN_ID, ...dataColumnsOrder] : dataColumnsOrder,
- );
+const getColumnOrder = (
+ dataColumnsOrder: string[],
+ utilityColumnIds: string[],
+) => _.uniq([...utilityColumnIds, ...dataColumnsOrder]);
/**
* Main hook for creating and managing a data grid instance.
@@ -62,9 +70,10 @@ export const useDataGridInstance = <TData, TValue>({
data,
columnOrder: controlledColumnOrder,
columnSizingMap: controlledColumnSizingMap,
- columnPinning: controlledColumnPinning,
+ pinnedLeftColumnsCount = 0,
+ pinnedTopRowsCount = 0,
sorting,
- defaultRowHeight = 36,
+ defaultRowHeight = ROW_HEIGHT,
minGridWidth: minGridWidthProp,
rowId,
truncateLongCellWidth = TRUNCATE_LONG_CELL_WIDTH,
@@ -80,14 +89,29 @@ export const useDataGridInstance = <TData, TValue>({
onColumnReorder,
measurementRenderWrapper,
}: DataGridOptions<TData, TValue>): DataGridInstance<TData> => {
+ const datasetIndexAttributeName = DATASET_INDEX_ATTRIBUTE_NAME;
+ const virtualIndexAttributeName = VIRTUAL_INDEX_ATTRIBUTE_NAME;
const gridRef = useRef<HTMLDivElement>(null);
- const hasRowIdColumn = rowId != null;
+
+ const utilityColumns = useMemo(
+ () =>
+ [
+ columnRowSelectOptions,
+ rowId ? getRowIdColumn<TData, TValue>(rowId) : null,
+ ].filter(isNotNull),
+ [rowId, columnRowSelectOptions],
+ );
+
+ const utilityColumnIds = useMemo(
+ () => utilityColumns.map((column) => column.id).filter(isNotNull),
+ [utilityColumns],
+ );
// Initialize column order (either controlled or from column options)
const [columnOrder, setColumnOrder] = useState<string[]>(
getColumnOrder(
controlledColumnOrder ?? columnsOptions.map((column) => column.id),
- hasRowIdColumn,
+ utilityColumnIds,
),
);
@@ -114,8 +138,10 @@ export const useDataGridInstance = <TData, TValue>({
// Update column order when controlled value changes
useLayoutEffect(() => {
- setColumnOrder(getColumnOrder(controlledColumnOrder ?? [], hasRowIdColumn));
- }, [controlledColumnOrder, hasRowIdColumn]);
+ setColumnOrder(
+ getColumnOrder(controlledColumnOrder ?? [], utilityColumnIds),
+ );
+ }, [controlledColumnOrder, utilityColumnIds]);
// Handler for updating column expanded state
const handleUpdateColumnExpanded = useCallback(
@@ -150,42 +176,34 @@ export const useDataGridInstance = <TData, TValue>({
],
);
- // Generate table columns configuration from options
- const columns = useMemo(() => {
- const rowIdColumnDefinition =
- rowId != null ? getRowIdColumn<TData, TValue>(rowId) : null;
-
- const dataColumns = columnsOptions.map((options) =>
- getDataColumn<TData, TValue>(
- options,
- columnSizingMap,
- measuredColumnSizingMap,
- expandedColumnsMap,
- truncateLongCellWidth,
- handleExpandButtonClick,
+ const dataColumns = useMemo(
+ () =>
+ columnsOptions.map((options) =>
+ getDataColumn<TData, TValue>(
+ options,
+ columnSizingMap,
+ measuredColumnSizingMap,
+ expandedColumnsMap,
+ truncateLongCellWidth,
+ handleExpandButtonClick,
+ ),
),
- );
+ [
+ columnsOptions,
+ columnSizingMap,
+ measuredColumnSizingMap,
+ expandedColumnsMap,
+ truncateLongCellWidth,
+ handleExpandButtonClick,
+ ],
+ );
- return [
- columnRowSelectOptions,
- rowIdColumnDefinition,
- ...dataColumns,
- ].filter(isNotNull);
- }, [
- rowId,
- columnsOptions,
- columnRowSelectOptions,
- columnSizingMap,
- measuredColumnSizingMap,
- expandedColumnsMap,
- truncateLongCellWidth,
- handleExpandButtonClick,
- ]);
+ const columns = useMemo(
+ () => [...utilityColumns, ...dataColumns],
+ [utilityColumns, dataColumns],
+ );
- // IDs of columns with fixed width that shouldn't be auto-resized
- const fixedWidthColumnIds = useMemo(() => {
- return [columnRowSelectOptions?.id, ROW_ID_COLUMN_ID].filter(isNotNull);
- }, [columnRowSelectOptions]);
+ const fixedWidthColumnIds = utilityColumnIds;
// Columns that need text wrapping
const wrappedColumnsOptions = useMemo(() => {
@@ -223,13 +241,39 @@ export const useDataGridInstance = <TData, TValue>({
: minGridWidthProp - getScrollBarSize();
}, [enablePagination, minGridWidthProp]);
+ const { columnPinning, toggle: toggleColumnPinningLimiter } =
+ useColumnPinningByCount({
+ gridRef,
+ columnOrder,
+ columnSizingMap,
+ pinnedColumnsCount: pinnedLeftColumnsCount + utilityColumns.length,
+ });
+
+ const { getRowHeight } = useRowSizing({
+ data,
+ defaultRowHeight,
+ columnSizingMap,
+ wrappedColumnsOptions,
+ measureBodyCellDimensions,
+ });
+
+ const [sortedRows, setSortedRows] = useState<Row<TData>[]>([]);
+
+ const rowPinning = useRowPinningByCount({
+ top: pinnedTopRowsCount,
+ sortedRows,
+ gridRef,
+ getRowHeight,
+ });
+
const table = useReactTable({
data,
columns,
state: {
columnSizing: columnSizingMap,
columnOrder,
- columnPinning: controlledColumnPinning ?? { left: [ROW_ID_COLUMN_ID] },
+ columnPinning,
+ rowPinning,
sorting,
pagination,
rowSelection: rowSelection ?? {},
@@ -247,53 +291,16 @@ export const useDataGridInstance = <TData, TValue>({
enableRowSelection,
});
- // Calculate dynamic row heights for wrapped columns
- const measureRowHeight = useCallback(
- (rowIndex: number) => {
- if (wrappedColumnsOptions.length === 0) {
- return defaultRowHeight;
- }
-
- const height = Math.max(
- ...wrappedColumnsOptions.map((column) => {
- const value = column.accessorFn(data[rowIndex]);
- const formattedValue = column.formatter
- ? column.formatter(value, rowIndex, column.id)
- : String(value);
-
- if (value == null || formattedValue === "") {
- return defaultRowHeight;
- }
- const tableColumn = table.getColumn(column.id);
-
- const cellDimensions = measureBodyCellDimensions(
- formattedValue,
- tableColumn?.getSize(),
- );
- return cellDimensions.height;
- }),
- defaultRowHeight,
- );
-
- return height;
- },
- [
- data,
- defaultRowHeight,
- measureBodyCellDimensions,
- table,
- wrappedColumnsOptions,
- ],
- );
-
// Enable row virtualization only when pagination is disabled
const enableRowVirtualization = !enablePagination;
const virtualGrid = useVirtualGrid({
gridRef,
table,
defaultRowHeight,
- measureRowHeight,
enableRowVirtualization,
+ getRowHeight,
+ datasetIndexAttributeName,
+ virtualIndexAttributeName,
});
const measureColumnWidths = useMeasureColumnWidths(
@@ -352,33 +359,37 @@ export const useDataGridInstance = <TData, TValue>({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- const { measureGrid, rowVirtualizer, columnVirtualizer } = virtualGrid;
+ // For pinning row state we need to work with client-side sorted data
+ useLayoutEffect(() => {
+ setSortedRows(table.getSortedRowModel().rows);
+ }, [sorting, data, table]);
+
+ const { measureGrid, columnVirtualizer } = virtualGrid;
const prevColumnSizing = useRef<ColumnSizingState>();
const prevWrappedColumns = useRef<string[]>();
- // Re-measure grid when column sizing or wrapping changes
useEffect(() => {
const didColumnSizingChange =
prevColumnSizing.current != null &&
!_.isEqual(prevColumnSizing.current, columnSizingMap);
+ const wrappedColumnIds = wrappedColumnsOptions.map((column) => column.id);
const didColumnWrappingChange =
prevWrappedColumns.current != null &&
- !_.isEqual(
- wrappedColumnsOptions.map((column) => column.id),
- prevWrappedColumns.current,
- );
+ !_.isEqual(wrappedColumnIds, prevWrappedColumns.current);
if (didColumnSizingChange || didColumnWrappingChange) {
measureGrid();
}
prevColumnSizing.current = columnSizingMap;
- prevWrappedColumns.current = wrappedColumnsOptions.map(
- (column) => column.id,
- );
+ prevWrappedColumns.current = wrappedColumnIds;
}, [columnSizingMap, measureGrid, wrappedColumnsOptions]);
+ useEffect(() => {
+ columnVirtualizer.measure();
+ }, [columnVirtualizer, columnOrder]);
+
// Handle column resize from resize observer
const handleColumnResize = useCallback(
(columnName: string, width: number) => {
@@ -408,26 +419,31 @@ export const useDataGridInstance = <TData, TValue>({
onColumnReorder,
);
- // Scroll to a specific row/column in the virtualized grid
+ const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;
+ const isInteracting = columnsReordering.isDragging || isResizingColumn;
+ useEffect(() => {
+ toggleColumnPinningLimiter(isInteracting);
+ }, [toggleColumnPinningLimiter, isInteracting]);
+
const scrollTo = useCallback(
- ({
- rowIndex,
- columnIndex,
- }: {
- rowIndex?: number;
- columnIndex?: number;
- }) => {
- if (rowIndex != null) {
- rowVirtualizer.scrollToIndex(rowIndex);
+ ({ row, column }: ScrollToDestinations) => {
+ if (row) {
+ const rowPinningCount = rowPinning.top?.length ?? 0;
+ const rowIndex = Math.max(row.index - rowPinningCount, 0);
+ virtualGrid.rowVirtualizer.scrollToIndex(rowIndex, row.options);
}
- if (columnIndex != null) {
- columnVirtualizer.scrollToIndex(columnIndex);
+ if (column) {
+ const columnPinningCount = columnPinning.left?.length ?? 0;
+ const columnIndex = Math.max(column.index - columnPinningCount, 0);
+ virtualGrid.columnVirtualizer.scrollToIndex(
+ columnIndex,
+ column.options,
+ );
}
},
- [rowVirtualizer, columnVirtualizer],
+ [virtualGrid, rowPinning, columnPinning],
);
- // Setup cell selection functionality
const selection = useCellSelection({
gridRef,
table,
@@ -449,20 +465,53 @@ export const useDataGridInstance = <TData, TValue>({
virtualGrid.rowVirtualizer,
]);
- // Get rows that should be currently visible in the viewport
- const getVisibleRows = useCallback(() => {
- if (enableRowVirtualization) {
- return virtualGrid.virtualRows.map((virtualRow) => {
- const row = table.getRowModel().rows[virtualRow.index];
- return {
- row,
- virtualRow,
- };
- });
+ const getPinnedRows = useCallback(
+ (): DataGridRowType<TData>[] =>
+ table.getTopRows().map((row, index) => ({
+ origin: row,
+ displayIndex: index,
+ height: getRowHeight(index),
+ })),
+ [table, getRowHeight],
+ );
+
+ const getCenterRows = useCallback((): DataGridRowType<TData>[] => {
+ const centerRows = table.getCenterRows();
+ const pinnedRowsCount = table.getTopRows().length;
+ if (!enableRowVirtualization) {
+ return centerRows.map((row, index) => ({
+ origin: row,
+ displayIndex: index + pinnedRowsCount,
+ height: getRowHeight(row.index),
+ }));
}
+ return virtualGrid.virtualRows.map((virtualRow) => ({
+ origin: centerRows[virtualRow.index],
+ virtualItem: virtualRow,
+ displayIndex: virtualRow.index + pinnedRowsCount,
+ height: virtualRow.size,
+ }));
+ }, [enableRowVirtualization, getRowHeight, table, virtualGrid.virtualRows]);
+
+ const getPinnedColumns = useCallback(
+ (): DataGridColumnType<TData>[] =>
+ table.getLeftVisibleLeafColumns().map((column) => ({
+ origin: column,
+ getCell: (row) => row.getLeftVisibleCells()[column.getIndex("left")],
+ })),
+ [table],
+ );
- return table.getRowModel().rows;
- }, [enableRowVirtualization, table, virtualGrid.virtualRows]);
+ const getCenterColumns = useCallback((): DataGridColumnType<TData>[] => {
+ const centerColumns = table.getCenterLeafColumns();
+ return virtualGrid.virtualColumns.map((virtualColumn) => {
+ return {
+ origin: centerColumns[virtualColumn.index],
+ virtualItem: virtualColumn,
+ getCell: (row) => row.getCenterVisibleCells()[virtualColumn.index],
+ };
+ });
+ }, [table, virtualGrid.virtualColumns]);
// Auto-adjust column widths when pagination changes
const previousPagination = usePrevious(pagination);
@@ -536,8 +585,14 @@ export const useDataGridInstance = <TData, TValue>({
selection,
enableRowVirtualization,
getTotalHeight,
- getVisibleRows,
+ getCenterRows,
+ getCenterColumns,
+ getPinnedColumns,
+ getPinnedRows,
+ rowMeasureRef: virtualGrid.rowMeasureRef,
+ datasetIndexAttributeName,
enablePagination,
sorting,
+ scrollTo,
};
};
diff --git a/frontend/src/metabase/data-grid/hooks/use-row-pinning-by-count.ts b/frontend/src/metabase/data-grid/hooks/use-row-pinning-by-count.ts
new file mode 100644
index 00000000000..ec40ed12ae7
--- /dev/null
+++ b/frontend/src/metabase/data-grid/hooks/use-row-pinning-by-count.ts
@@ -0,0 +1,40 @@
+import type { Row, RowPinningState } from "@tanstack/react-table";
+import type { RefObject } from "react";
+import { useMemo } from "react";
+
+import { HEADER_HEIGHT } from "../constants";
+import { countWithinLimit } from "../utils/count-within-limit";
+
+type UseRowPinningByCountProps<TData> = {
+ top?: number;
+ sortedRows: Row<TData>[];
+ gridRef: RefObject<HTMLDivElement | null>;
+ getRowHeight: (index: number) => number;
+};
+
+export const useRowPinningByCount = <TData>({
+ top = 0,
+ sortedRows,
+ gridRef,
+ getRowHeight,
+}: UseRowPinningByCountProps<TData>): RowPinningState => {
+ const containerHeight =
+ gridRef.current?.getBoundingClientRect().height ?? window.innerHeight;
+
+ return useMemo(() => {
+ const maxHeight = containerHeight * 0.8;
+
+ const candidateSizes = [HEADER_HEIGHT];
+ const cap = Math.min(top, sortedRows.length);
+ for (let index = 0; index < cap; index++) {
+ candidateSizes.push(getRowHeight(index));
+ }
+
+ const includedCount = countWithinLimit(candidateSizes, maxHeight);
+ const pinnedRowsCount = Math.max(0, includedCount - 1);
+
+ const topIds = sortedRows.slice(0, pinnedRowsCount).map((row) => row.id);
+
+ return { top: topIds };
+ }, [containerHeight, sortedRows, top, getRowHeight]);
+};
diff --git a/frontend/src/metabase/data-grid/hooks/use-row-sizing.ts b/frontend/src/metabase/data-grid/hooks/use-row-sizing.ts
new file mode 100644
index 00000000000..c092c60b487
--- /dev/null
+++ b/frontend/src/metabase/data-grid/hooks/use-row-sizing.ts
@@ -0,0 +1,53 @@
+import type { ColumnSizingState, RowData } from "@tanstack/react-table";
+import { useCallback } from "react";
+
+import type { ColumnOptions } from "../types";
+
+type UseRowSizingProps<TData extends RowData, TValue> = {
+ data: TData[];
+ defaultRowHeight: number;
+ columnSizingMap: ColumnSizingState;
+ wrappedColumnsOptions: ColumnOptions<TData, TValue>[];
+ measureBodyCellDimensions: (
+ text: React.ReactNode,
+ width?: number,
+ ) => { width: number; height: number };
+};
+
+export const useRowSizing = <TData extends RowData, TValue>({
+ data,
+ defaultRowHeight,
+ columnSizingMap,
+ wrappedColumnsOptions,
+ measureBodyCellDimensions,
+}: UseRowSizingProps<TData, TValue>) => {
+ const getRowHeight = useCallback(
+ (index: number): number =>
+ wrappedColumnsOptions.reduce((max, column) => {
+ const value = column.accessorFn(data[index]);
+ const formatted = column.formatter
+ ? column.formatter(value, index, column.id)
+ : String(value);
+
+ if (value === null || value === undefined || formatted === "") {
+ return max;
+ }
+ const width = columnSizingMap[column.id];
+ try {
+ const height = measureBodyCellDimensions(formatted, width).height;
+ return Math.max(height, max);
+ } catch {
+ return max;
+ }
+ }, defaultRowHeight),
+ [
+ data,
+ defaultRowHeight,
+ columnSizingMap,
+ wrappedColumnsOptions,
+ measureBodyCellDimensions,
+ ],
+ );
+
+ return { getRowHeight };
+};
diff --git a/frontend/src/metabase/data-grid/hooks/use-virtual-grid.tsx b/frontend/src/metabase/data-grid/hooks/use-virtual-grid.tsx
index 772434cb5bf..b6c3ab326e0 100644
--- a/frontend/src/metabase/data-grid/hooks/use-virtual-grid.tsx
+++ b/frontend/src/metabase/data-grid/hooks/use-virtual-grid.tsx
@@ -1,130 +1,98 @@
import type { Table as ReactTable } from "@tanstack/react-table";
import {
- type Range,
type VirtualItem,
type Virtualizer,
- defaultRangeExtractor,
useVirtualizer,
} from "@tanstack/react-virtual";
import type React from "react";
import { useCallback, useMemo } from "react";
-interface VirtualGridOptions<TData> {
+interface VirtualGridProps<TData> {
gridRef: React.RefObject<HTMLDivElement>;
table: ReactTable<TData>;
- measureRowHeight: (rowIndex: number) => number;
defaultRowHeight: number;
enableRowVirtualization?: boolean;
+ getRowHeight: (index: number) => number;
+ datasetIndexAttributeName: string;
+ virtualIndexAttributeName: string;
}
export interface VirtualGrid {
virtualColumns: VirtualItem[];
virtualRows: VirtualItem[];
- virtualPaddingLeft: number | undefined;
- virtualPaddingRight: number | undefined;
rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
columnVirtualizer: Virtualizer<HTMLDivElement, Element>;
+ rowMeasureRef: (element: Element | null) => void;
measureGrid: () => void;
+ virtualIndexAttributeName: string;
}
export const useVirtualGrid = <TData,>({
gridRef,
table,
- measureRowHeight,
defaultRowHeight,
enableRowVirtualization,
-}: VirtualGridOptions<TData>): VirtualGrid => {
- const { rows: tableRows } = table.getRowModel();
- const visibleColumns = table.getVisibleLeafColumns();
-
- const pinnedColumnsIndices = useMemo(
- () => table.getLeftVisibleLeafColumns().map((c) => c.getPinnedIndex()),
- [table],
- );
+ getRowHeight,
+ datasetIndexAttributeName,
+ virtualIndexAttributeName,
+}: VirtualGridProps<TData>): VirtualGrid => {
+ const centerColumns = table.getCenterLeafColumns();
+ const centerRows = table.getCenterRows();
+ const leftPinnedColumnsWidth = table.getLeftTotalSize();
const columnVirtualizer = useVirtualizer({
- count: visibleColumns.length,
+ count: centerColumns.length,
getScrollElement: () => gridRef.current,
- estimateSize: (index) => {
- const column = visibleColumns[index];
- const size = visibleColumns[index].getSize();
- const actualSize = table.getState().columnSizing[column.id];
- return actualSize ?? size;
- },
- rangeExtractor: useCallback(
- (range: Range) => {
- const columnIndices = defaultRangeExtractor(range);
- if (pinnedColumnsIndices.length === 0) {
- return columnIndices;
- }
- return Array.from(new Set([...pinnedColumnsIndices, ...columnIndices]));
- },
- [pinnedColumnsIndices],
- ),
+ estimateSize: (index) => centerColumns[index].getSize(),
horizontal: true,
overscan: 3,
+ scrollMargin: leftPinnedColumnsWidth,
});
const rowVirtualizer = useVirtualizer({
- count: tableRows.length,
+ count: centerRows.length,
+ indexAttribute: virtualIndexAttributeName,
getScrollElement: () => gridRef.current,
estimateSize: () => defaultRowHeight,
overscan: 3,
enabled: enableRowVirtualization,
measureElement: (element) => {
- const rowIndexRaw = element?.getAttribute("data-dataset-index");
- const rowIndex = rowIndexRaw != null ? parseInt(rowIndexRaw, 10) : null;
- if (rowIndex == null || !isFinite(rowIndex)) {
+ const indexRaw = element.getAttribute(datasetIndexAttributeName);
+ if (!indexRaw) {
return defaultRowHeight;
}
-
- return measureRowHeight(rowIndex);
+ const index = parseInt(indexRaw, 10);
+ return getRowHeight(index);
},
});
+ const rawVirtualColumns = columnVirtualizer.getVirtualItems();
+ const virtualColumns = useMemo(
+ () =>
+ rawVirtualColumns.map((item) => ({
+ ...item,
+ start: item.start - leftPinnedColumnsWidth,
+ end: item.end - leftPinnedColumnsWidth,
+ })),
+ [rawVirtualColumns, leftPinnedColumnsWidth],
+ );
+
+ const virtualRows = rowVirtualizer.getVirtualItems();
+
const measureGrid = useCallback(() => {
- Array.from(rowVirtualizer.elementsCache.values()).forEach((el) =>
- rowVirtualizer.measureElement(el),
+ Array.from(rowVirtualizer.elementsCache.values()).forEach((element) =>
+ rowVirtualizer.measureElement(element),
);
columnVirtualizer.measure();
}, [rowVirtualizer, columnVirtualizer]);
- const virtualColumns = columnVirtualizer.getVirtualItems();
- const virtualRows = rowVirtualizer.getVirtualItems();
-
- return useMemo(() => {
- let virtualPaddingLeft: number | undefined;
- let virtualPaddingRight: number | undefined;
-
- const pinnedCount = pinnedColumnsIndices.length;
-
- if (columnVirtualizer && virtualColumns?.length) {
- const leftNonPinnedStart = virtualColumns[pinnedCount]?.start ?? 0;
- const leftNonPinnedEnd =
- virtualColumns[pinnedColumnsIndices.length - 1]?.end ?? 0;
-
- virtualPaddingLeft = leftNonPinnedStart - leftNonPinnedEnd;
-
- virtualPaddingRight =
- columnVirtualizer.getTotalSize() -
- (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
- }
-
- return {
- virtualColumns,
- virtualRows,
- virtualPaddingLeft,
- virtualPaddingRight,
- rowVirtualizer,
- columnVirtualizer,
- measureGrid,
- };
- }, [
+ return {
virtualColumns,
virtualRows,
rowVirtualizer,
columnVirtualizer,
- pinnedColumnsIndices.length,
+ rowMeasureRef: rowVirtualizer.measureElement,
measureGrid,
- ]);
+ virtualIndexAttributeName,
+ };
};
diff --git a/frontend/src/metabase/data-grid/index.ts b/frontend/src/metabase/data-grid/index.ts
index c9767b0062d..e22bd8d7331 100644
--- a/frontend/src/metabase/data-grid/index.ts
+++ b/frontend/src/metabase/data-grid/index.ts
@@ -1,4 +1,5 @@
export * from "./components/DataGrid/DataGrid";
+export * from "./components/DataGrid/types";
export * from "./components/BaseCell/BaseCell";
export * from "./components/HeaderCell/HeaderCell";
export * from "./components/BodyCell/BodyCell";
diff --git a/frontend/src/metabase/data-grid/types.ts b/frontend/src/metabase/data-grid/types.ts
index ac4eff71b3f..12fdcf054bf 100644
--- a/frontend/src/metabase/data-grid/types.ts
+++ b/frontend/src/metabase/data-grid/types.ts
@@ -1,8 +1,8 @@
import type {
Cell,
CellContext,
+ Column,
ColumnDefTemplate,
- ColumnPinningState,
ColumnSizingState,
HeaderContext,
OnChangeFn,
@@ -13,8 +13,7 @@ import type {
SortingState,
Table,
} from "@tanstack/react-table";
-import type { VirtualItem } from "@tanstack/react-virtual";
-import type React from "react";
+import type { ScrollToOptions, VirtualItem } from "@tanstack/react-virtual";
import type { RefObject } from "react";
import type { ColumnsReordering } from "./hooks/use-columns-reordering";
@@ -30,6 +29,7 @@ declare module "@tanstack/react-table" {
formatter?: CellFormatter<TValue>;
clipboardFormatter?: PlainCellFormatter<TValue>;
width?: "auto";
+ isUtilityColumn?: boolean;
}
}
@@ -177,8 +177,14 @@ export interface DataGridOptions<TData = any, TValue = any> {
/** Width of each column by ID */
columnSizingMap?: ColumnSizingState;
- /** Pinning state of columns */
- columnPinning?: ColumnPinningState;
+ /** Number of left-pinned data columns (excluding rowId) */
+ pinnedLeftColumnsCount?: number;
+
+ /** number of top pinned rows */
+ pinnedTopRowsCount?: number;
+
+ /** Custom row ID accessor */
+ getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;
/** Array of column sorting options */
sorting?: SortingState;
@@ -287,6 +293,16 @@ export type CellId = {
cellId: string;
};
+export type ScrollToDestination = {
+ index: number;
+ options?: ScrollToOptions;
+};
+
+export type ScrollToDestinations = {
+ row?: ScrollToDestination;
+ column?: ScrollToDestination;
+};
+
export interface DataGridInstance<TData> {
table: Table<TData>;
gridRef: RefObject<HTMLDivElement>;
@@ -299,7 +315,13 @@ export interface DataGridInstance<TData> {
theme?: DataGridTheme;
sorting: SortingState | undefined;
getTotalHeight: () => number;
- getVisibleRows: () => MaybeVirtualRow<TData>[];
+ getCenterRows: () => DataGridRowType<TData>[];
+ getPinnedRows: () => DataGridRowType<TData>[];
+ getPinnedColumns: () => DataGridColumnType<TData>[];
+ getCenterColumns: () => DataGridColumnType<TData>[];
+ datasetIndexAttributeName: string;
+ rowMeasureRef: (element: Element | null) => void;
+ scrollTo: (destinations: ScrollToDestinations) => void;
onHeaderCellClick?: (
event: React.MouseEvent<HTMLDivElement>,
columnId?: string,
@@ -313,9 +335,15 @@ export interface DataGridInstance<TData> {
onWheel?: React.UIEventHandler<HTMLDivElement>;
}
-export type VirtualRow<TData> = {
- row: Row<TData>;
- virtualRow: VirtualItem;
+export type DataGridRowType<TData> = {
+ origin: Row<TData>;
+ virtualItem?: VirtualItem;
+ displayIndex: number;
+ height: number;
};
-export type MaybeVirtualRow<TData> = Row<TData> | VirtualRow<TData>;
+export type DataGridColumnType<TData, TValue = unknown> = {
+ origin: Column<TData, TValue>;
+ virtualItem?: VirtualItem;
+ getCell: (row: Row<TData>) => Cell<TData, TValue>;
+};
diff --git a/frontend/src/metabase/data-grid/utils/columns/row-id-column.tsx b/frontend/src/metabase/data-grid/utils/columns/row-id-column.tsx
index 04a4916d56b..245534cd934 100644
--- a/frontend/src/metabase/data-grid/utils/columns/row-id-column.tsx
+++ b/frontend/src/metabase/data-grid/utils/columns/row-id-column.tsx
@@ -25,6 +25,7 @@ export const getRowIdColumn = <TRow, TValue>({
enableSorting: false,
enableResizing: false,
enablePinning: true,
+ meta: { isUtilityColumn: true },
cell: ({ row, table }) => {
// HACK: When table has client-side sorting we cannot use row.index for the index column as it shows
// row index in the original dataset
diff --git a/frontend/src/metabase/data-grid/utils/count-within-limit.ts b/frontend/src/metabase/data-grid/utils/count-within-limit.ts
new file mode 100644
index 00000000000..51e022362f0
--- /dev/null
+++ b/frontend/src/metabase/data-grid/utils/count-within-limit.ts
@@ -0,0 +1,10 @@
+export const countWithinLimit = (sizes: number[], limit: number): number => {
+ let total = 0;
+ for (let index = 0; index < sizes.length; index++) {
+ total += sizes[index];
+ if (total > limit) {
+ return index;
+ }
+ }
+ return sizes.length;
+};
diff --git a/frontend/src/metabase/data-grid/utils/stylings.ts b/frontend/src/metabase/data-grid/utils/stylings.ts
new file mode 100644
index 00000000000..822d3a6bef5
--- /dev/null
+++ b/frontend/src/metabase/data-grid/utils/stylings.ts
@@ -0,0 +1,26 @@
+import type React from "react";
+
+import type { DataGridColumnType, DataGridRowType } from "../types";
+
+export const getRowPositionStyles = <TData>(
+ row: DataGridRowType<TData>,
+): React.CSSProperties => {
+ if (!row.virtualItem) {
+ return {
+ minHeight: `${row.height}px`,
+ };
+ }
+ return {
+ position: "absolute",
+ top: 0,
+ left: 0,
+ minHeight: `${row.height}px`,
+ transform: `translateY(${row.virtualItem.start}px)`,
+ };
+};
+
+export const getColumnPositionStyles = <TData>(
+ column: DataGridColumnType<TData>,
+): React.CSSProperties => {
+ return { width: column.origin.getSize() };
+};
diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts b/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
index 52935ad6bc7..af84a3c2c1f 100644
--- a/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
@@ -10,7 +10,7 @@ import type {
Table,
} from "@tanstack/react-table";
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
-import type { InitialTableState } from "@tanstack/table-core/src/types";
+import type { InitialTableState } from "@tanstack/table-core";
import type {
CSSProperties,
KeyboardEvent,
diff --git a/frontend/src/metabase/visualizations/components/ChartSettings/BaseChartSettings/hooks.ts b/frontend/src/metabase/visualizations/components/ChartSettings/BaseChartSettings/hooks.ts
index cdafebfbce6..3a9fdc3d96a 100644
--- a/frontend/src/metabase/visualizations/components/ChartSettings/BaseChartSettings/hooks.ts
+++ b/frontend/src/metabase/visualizations/components/ChartSettings/BaseChartSettings/hooks.ts
@@ -43,6 +43,7 @@ export const useChartSettingsSections = ({
const sectionSortOrder = [
"data",
+ "columns",
"display",
"axes",
"ranges",
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.module.css b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.module.css
index 1ed60b7a9a4..269f1f4d90d 100644
--- a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.module.css
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.module.css
@@ -2,6 +2,8 @@
width: 100%;
height: 100%;
overflow: hidden;
+ display: flex;
+ flex-direction: column;
.bodyCellWithImage {
padding-top: 3px;
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
index bcb529d1b50..338c82bdc91 100644
--- a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx
@@ -14,7 +14,6 @@ import {
useRef,
useState,
} from "react";
-import { useLatest } from "react-use";
import { t } from "ttag";
import _ from "underscore";
@@ -71,6 +70,7 @@ import type {
} from "metabase-types/api";
import S from "./TableInteractive.module.css";
+import { TableInteractiveContextProvider } from "./TableInteractiveContext";
import {
HeaderCellWithColumnInfo,
type HeaderCellWithColumnInfoProps,
@@ -179,9 +179,6 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
}: TableProps,
ref: Ref<HTMLDivElement>,
) {
- const getInfoPopoversDisabledRef = useLatest(() => {
- return clicked !== null || !hasMetadataPopovers || isDashboard;
- });
const tableTheme = theme?.other?.table;
const dispatch = useDispatch();
const isClientSideSortingEnabled = isDashboard;
@@ -534,7 +531,6 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
className={cx({
[S.pivotedFirstColumn]: columnIndex === 0 && isPivoted,
})}
- getInfoPopoversDisabled={getInfoPopoversDisabledRef.current}
timezone={data.results_timezone}
question={question}
column={col}
@@ -600,7 +596,6 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
tableTheme,
isDashboard,
tc,
- getInfoPopoversDisabledRef,
]);
const handleColumnResize = useCallback(
@@ -710,12 +705,31 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
return isDashcardViewTable || isEmbeddingSdk ? width : undefined;
}, [isDashcardViewTable, isEmbeddingSdk, width]);
+ const pinnedLeftColumnsCount = useMemo<number | undefined>(() => {
+ if (isPivoted || !settings["table.freeze_columns"]) {
+ return undefined;
+ }
+ return Math.min(
+ settings["table.freeze_columns_count"],
+ columnsOptions.length,
+ );
+ }, [isPivoted, settings, columnsOptions]);
+
+ const pinnedTopRowsCount = useMemo<number | undefined>(() => {
+ if (isPivoted || !settings["table.freeze_rows"]) {
+ return undefined;
+ }
+ return Math.min(settings["table.freeze_rows_count"], rows.length);
+ }, [isPivoted, settings, rows]);
+
const tableProps = useDataGridInstance({
data: rows,
rowId,
sorting,
columnOrder,
columnSizingMap,
+ pinnedLeftColumnsCount,
+ pinnedTopRowsCount,
columnsOptions,
theme: dataGridTheme,
onColumnResize: handleColumnResize,
@@ -724,7 +738,16 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
minGridWidth,
enableSelection: true,
});
- const { virtualGrid } = tableProps;
+ const { getCenterColumns, scrollTo, columnsReordering } = tableProps;
+ const infoPopoversDisabled =
+ clicked !== null ||
+ !hasMetadataPopovers ||
+ isDashboard ||
+ columnsReordering.isDragging;
+ const tableInteractiveContextValue = useMemo(
+ () => ({ infoPopoversDisabled }),
+ [infoPopoversDisabled],
+ );
// If the data changes we reset saved column widths as it is no longer relevant
// except for the case where question is converted from a model to a question and back.
@@ -732,20 +755,16 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
const scrolledColumnRef = useRef<number | null>(null);
useEffect(() => {
- const hasColumns = virtualGrid.virtualColumns.length > 0;
+ const hasColumns = getCenterColumns().length > 0;
if (hasColumns && scrollToLastColumn) {
- virtualGrid.columnVirtualizer.scrollToIndex(
- tableProps.table.getAllColumns().length,
- {
- align: "end",
- },
- );
+ const lastIndex = tableProps.table.getAllColumns().length - 1;
+ scrollTo({ column: { index: lastIndex, options: { align: "end" } } });
dispatch(setUIControls({ scrollToLastColumn: false }));
} else if (
scrollToColumn != null &&
scrolledColumnRef.current !== scrollToColumn
) {
- virtualGrid.columnVirtualizer.scrollToIndex(scrollToColumn);
+ scrollTo({ column: { index: scrollToColumn } });
scrolledColumnRef.current = scrollToColumn;
}
}, [
@@ -753,7 +772,8 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
scrollToLastColumn,
dispatch,
tableProps.table,
- virtualGrid,
+ getCenterColumns,
+ scrollTo,
]);
const handleWheel = useCallback(() => {
@@ -787,25 +807,27 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(
(isDashboard || mode == null || isRawTable) && !isSettings;
return (
- <div
- ref={ref}
- className={cx(S.root, DashboardS.fullscreenNormalText, className)}
- >
- <DataGrid
- {...tableProps}
- styles={dataGridStyles}
- showRowsCount={isDashboard}
- rowsTruncated={data.rows_truncated}
- isColumnReorderingDisabled={isColumnReorderingDisabled}
- emptyState={emptyState}
- zoomedRowIndex={zoomedRowIndex}
- onBodyCellClick={handleBodyCellClick}
- onAddColumnClick={handleAddColumnButtonClick}
- onHeaderCellClick={handleHeaderCellClick}
- onWheel={handleWheel}
- tableFooterExtraButtons={tableFooterExtraButtons}
- />
- </div>
+ <TableInteractiveContextProvider value={tableInteractiveContextValue}>
+ <div
+ ref={ref}
+ className={cx(S.root, DashboardS.fullscreenNormalText, className)}
+ >
+ <DataGrid
+ {...tableProps}
+ styles={dataGridStyles}
+ showRowsCount={isDashboard}
+ rowsTruncated={data.rows_truncated}
+ isColumnReorderingDisabled={isColumnReorderingDisabled}
+ emptyState={emptyState}
+ zoomedRowIndex={zoomedRowIndex}
+ onBodyCellClick={handleBodyCellClick}
+ onAddColumnClick={handleAddColumnButtonClick}
+ onHeaderCellClick={handleHeaderCellClick}
+ onWheel={handleWheel}
+ tableFooterExtraButtons={tableFooterExtraButtons}
+ />
+ </div>
+ </TableInteractiveContextProvider>
);
});
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractiveContext.ts b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractiveContext.ts
new file mode 100644
index 00000000000..d83911c2e3e
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractiveContext.ts
@@ -0,0 +1,14 @@
+import { createContext, useContext } from "react";
+
+interface TableInteractiveContextValue {
+ infoPopoversDisabled: boolean;
+}
+
+const TableInteractiveContext = createContext<TableInteractiveContextValue>({
+ infoPopoversDisabled: false,
+});
+
+export const TableInteractiveContextProvider = TableInteractiveContext.Provider;
+
+export const useTableInteractiveContext = () =>
+ useContext(TableInteractiveContext);
diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/cells/HeaderCellWithColumnInfo.tsx b/frontend/src/metabase/visualizations/components/TableInteractive/cells/HeaderCellWithColumnInfo.tsx
index 8d425032de3..f65860b3477 100644
--- a/frontend/src/metabase/visualizations/components/TableInteractive/cells/HeaderCellWithColumnInfo.tsx
+++ b/frontend/src/metabase/visualizations/components/TableInteractive/cells/HeaderCellWithColumnInfo.tsx
@@ -12,10 +12,11 @@ import * as Lib from "metabase-lib";
import type Question from "metabase-lib/v1/Question";
import type { DatasetColumn } from "metabase-types/api";
+import { useTableInteractiveContext } from "../TableInteractiveContext";
+
import S from "./HeaderCellWithColumnInfo.module.css";
export interface HeaderCellWithColumnInfoProps extends HeaderCellProps {
- getInfoPopoversDisabled: () => boolean;
timezone?: string;
question: Question;
column: DatasetColumn;
@@ -35,7 +36,6 @@ export const HeaderCellWithColumnInfo = memo(
align,
sort,
variant = "light",
- getInfoPopoversDisabled,
question,
timezone,
column,
@@ -44,6 +44,8 @@ export const HeaderCellWithColumnInfo = memo(
className,
renderTableHeader,
}: HeaderCellWithColumnInfoProps) {
+ const { infoPopoversDisabled } = useTableInteractiveContext();
+
const headerCellOverride = useMemo(() => {
return renderTableHeader != null
? renderTableHeader(column, columnIndex, theme)
@@ -62,7 +64,7 @@ export const HeaderCellWithColumnInfo = memo(
let headerContent: React.ReactNode;
- if (getInfoPopoversDisabled()) {
+ if (infoPopoversDisabled) {
headerContent = cellContent;
} else {
// question.query will throw when used in the visualizer
diff --git a/frontend/src/metabase/visualizations/components/settings/ChartSettingNumberInput.tsx b/frontend/src/metabase/visualizations/components/settings/ChartSettingNumberInput.tsx
new file mode 100644
index 00000000000..17046a2b9e8
--- /dev/null
+++ b/frontend/src/metabase/visualizations/components/settings/ChartSettingNumberInput.tsx
@@ -0,0 +1,38 @@
+import { NumberInput } from "metabase/ui";
+
+import type { ChartSettingWidgetProps } from "./types";
+
+interface ChartSettingNumberInputProps
+ extends Omit<ChartSettingWidgetProps<number>, "onChangeSettings"> {
+ id?: string;
+ placeholder?: string;
+ min?: number;
+ max?: number;
+}
+
+export const ChartSettingNumberInput = ({
+ value,
+ onChange,
+ id,
+ placeholder,
+ min = -Infinity,
+ max = Infinity,
+}: ChartSettingNumberInputProps) => {
+ const handleChange = (newValue: number | string) => {
+ onChange(Number(newValue));
+ };
+
+ return (
+ <NumberInput
+ id={id}
+ value={value}
+ onChange={handleChange}
+ placeholder={placeholder}
+ min={min}
+ max={max}
+ allowDecimal={false}
+ allowNegative={min < 0}
+ hideControls={false}
+ />
+ );
+};
diff --git a/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx b/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
index 9c7c95e4cc2..e070f6c9bbf 100644
--- a/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
@@ -8,6 +8,7 @@ import { displayNameForColumn } from "metabase/lib/formatting";
import type { OptionsType } from "metabase/lib/formatting/types";
import { getSubpathSafeUrl } from "metabase/lib/urls";
import ChartSettingLinkUrlInput from "metabase/visualizations/components/settings/ChartSettingLinkUrlInput";
+import { ChartSettingNumberInput } from "metabase/visualizations/components/settings/ChartSettingNumberInput";
import {
ChartSettingsTableFormatting,
isFormattable,
@@ -106,7 +107,7 @@ export class Table extends Component<TableProps, TableState> {
},
"table.row_index": {
get section() {
- return t`Columns`;
+ return t`Display`;
},
get title() {
return t`Show row index`;
@@ -115,6 +116,66 @@ export class Table extends Component<TableProps, TableState> {
widget: "toggle",
getDefault: () => false,
},
+ "table.freeze_columns": {
+ get section() {
+ return t`Display`;
+ },
+ get title() {
+ return t`Freeze columns`;
+ },
+ inline: true,
+ widget: "toggle",
+ default: false,
+ getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
+ _isPivoted(series, settings),
+ readDependencies: ["table.pivot"],
+ },
+ "table.freeze_columns_count": {
+ get section() {
+ return t`Display`;
+ },
+ get title() {
+ return t`Number of columns to freeze`;
+ },
+ widget: ChartSettingNumberInput,
+ default: 1,
+ isValid: (_series: Series, settings: VisualizationSettings) =>
+ settings["table.freeze_columns_count"] >= 1,
+ getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
+ !settings["table.freeze_columns"] || _isPivoted(series, settings),
+ readDependencies: ["table.freeze_columns", "table.pivot"],
+ getProps: () => ({ min: 1 }),
+ },
+ "table.freeze_rows": {
+ get section() {
+ return t`Display`;
+ },
+ get title() {
+ return t`Freeze rows`;
+ },
+ inline: true,
+ widget: "toggle",
+ default: false,
+ getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
+ _isPivoted(series, settings),
+ readDependencies: ["table.pivot"],
+ },
+ "table.freeze_rows_count": {
+ get section() {
+ return t`Display`;
+ },
+ get title() {
+ return t`Number of rows to freeze`;
+ },
+ widget: ChartSettingNumberInput,
+ default: 1,
+ isValid: (_series: Series, settings: VisualizationSettings) =>
+ settings["table.freeze_rows_count"] >= 1,
+ getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
+ !settings["table.freeze_rows"] || _isPivoted(series, settings),
+ readDependencies: ["table.freeze_rows", "table.pivot"],
+ getProps: () => ({ min: 1 }),
+ },
"table.pivot": {
get section() {
return t`Columns`;
diff --git a/package.json b/package.json
index a3d3b5bdb17..61396062ac3 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,7 @@
"@react-oauth/google": "^0.11.1",
"@reduxjs/toolkit": "^2.5.0",
"@snowplow/browser-tracker": "^3.1.6",
- "@tanstack/react-table": "^8.21.2",
+ "@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.2",
"@tippyjs/react": "^4.2.6",
"@tiptap/core": "^3.2.0",