A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: truncate long column names in columns menu (#10831)
Myles Scolnick8533cd25a43e
diff --git a/frontend/src/components/data-table/column-visibility-dropdown.tsx b/frontend/src/components/data-table/column-visibility-dropdown.tsxindex 7e6b732e23..a2362dca72 100644--- a/frontend/src/components/data-table/column-visibility-dropdown.tsx+++ b/frontend/src/components/data-table/column-visibility-dropdown.tsx@@ -215,6 +215,11 @@ export const ColumnVisibilityDropdown = <TData,>({index === list.pinnedCount &&list.pinnedCount > 0 &&list.pinnedCount < list.visibleOptions.length;+ const label = (+ <span className="truncate" title={option.label}>+ {option.label}+ </span>+ );return (<React.Fragment key={option.value}>{isSectionBoundary && <CommandSeparator />}@@ -225,15 +230,16 @@ export const ColumnVisibilityDropdown = <TData,>({className="flex items-center gap-1.5 cursor-pointer">{dataType === undefined ? (- <span>{option.label}</span>+ label) : (<ColumnName- columnName={option.label}+ className="min-w-0"+ columnName={label}dataType={dataType}/>)}{!option.disabled && (- <span className="ml-auto flex items-center gap-0.5">+ <span className="ml-auto flex shrink-0 items-center gap-0.5"><ShowOnlyColumnButtontable={table}columnIds={[option.value]}diff --git a/frontend/src/components/datasources/components.tsx b/frontend/src/components/datasources/components.tsxindex 98fac43ef1..3934ce6562 100644--- a/frontend/src/components/datasources/components.tsx+++ b/frontend/src/components/datasources/components.tsx@@ -101,18 +101,20 @@ export const ColumnPreviewContainer: React.FC<{export const ColumnName = ({columnName,dataType,+ className,}: {columnName: React.ReactNode;dataType: DataType;+ className?: string;}) => {const resolvedDataType = resolveDataType(dataType);const Icon = DATA_TYPE_ICON[resolvedDataType];const color = getDataTypeColor(resolvedDataType);return (- <div className="flex flex-row items-center gap-1.5">+ <div className={cn("flex flex-row items-center gap-1.5", className)}><Icon- className={`w-4 h-4 p-0.5 rounded-sm stroke-card-foreground ${color}`}+ className={`w-4 h-4 shrink-0 p-0.5 rounded-sm stroke-card-foreground ${color}`}/>{columnName}</div>diff --git a/marimo/_smoke_tests/issues/10813_column_menu.py b/marimo/_smoke_tests/issues/10813_column_menu.pynew file mode 100644index 0000000000..85fa3f9335--- /dev/null+++ b/marimo/_smoke_tests/issues/10813_column_menu.py@@ -0,0 +1,69 @@+# /// script+# requires-python = ">=3.10"+# dependencies = ["marimo", "pandas"]+# ///++import marimo++__generated_with = "0.24.2"+app = marimo.App(width="medium")+++def _():+ import marimo as mo+ import pandas as pd++ return mo, pd++[email protected](hide_code=True)+def _(mo):+ mo.md("""+ # Columns menu: long names++ Open **Columns** in the table below.++ 1. Check that long names end in an ellipsis and the type icons remain visible.+ 2. Hover over a truncated name to see its full name.+ 3. Check that the show-only and eye icons stay aligned for short and long names.+ 4. Click an eye icon to hide and restore a column. Click the show-only icon+ to isolate a long-named column, then use **Show all** to restore the table.+ 5. Search for `External_ID`, repeat the actions, then clear the search.+ 6. Scroll to the bottom of the menu and check the last row's actions.+ """)+ return+++def _(mo, pd):+ df = pd.DataFrame(+ {+ "ID": [1, 2, 3],+ "Include_ACT_OS_Analysis": [1, 2, 3],+ "Include_ACT_RFI_Analysis": [1, 2, 3],+ "Include_NoTreat_OS_Analysis": [1, 2, 3],+ "Include_NoTreat_RFI_Analysis": [1, 2, 3],+ "External_ID_matching_normal_sample": ["A", "B", "C"],+ "External_ID_" + "very_long_column_name_" * 8: [1.5, 2.5, 3.5],+ "A long column name with spaces that should remain on one line": [+ True,+ False,+ True,+ ],+ **{+ f"Extra_column_{index:02d}_with_a_long_name_for_scrolling": [+ 1,+ 2,+ 3,+ ]+ for index in range(20)+ },+ }+ )+ mo.ui.table(df, label="Long column names", selection=None)+ return+++if __name__ == "__main__":+ app.run()