From 68966880c2e7238cc76ff3ef151eeefeb44bf8ca Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 18 Mar 2026 09:46:36 -0700 Subject: [PATCH] Fix mobile column actions not showing items for SQL views (#2670) * Fix mobile column actions not showing items for SQL views The previous fix to exclude the Link column from mobile column actions (d02072b) used .dropdown-menu-icon presence as a proxy, but dropdown icons are only added to sortable columns (those with tags). This caused all non-sortable columns to be excluded too. Instead, explicitly mark the Link column with a data-is-link-column attribute and filter by that in mobileColumnHeaders, so non-sortable columns on views and tables still appear in the mobile column actions. * Prettier formatting for mobile-column-actions.js https://claude.ai/code/session_01CG545gLcZxet7dS5nMzfCd --- datasette/static/mobile-column-actions.js | 4 +--- datasette/templates/_table.html | 2 +- datasette/views/table.py | 1 + tests/test_table_html.py | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datasette/static/mobile-column-actions.js b/datasette/static/mobile-column-actions.js index bad963bf..a386b1fc 100644 --- a/datasette/static/mobile-column-actions.js +++ b/datasette/static/mobile-column-actions.js @@ -5,9 +5,7 @@ var MOBILE_COLUMN_DIALOG_TITLE_ID = "mobile-column-actions-title"; function mobileColumnHeaders(manager) { return Array.from( document.querySelectorAll(manager.selectors.tableHeaders), - ).filter( - (th) => th.dataset.column && th.querySelector(".dropdown-menu-icon"), - ); + ).filter((th) => th.dataset.column && th.dataset.isLinkColumn !== "1"); } function mobileColumnMetaText(th) { diff --git a/datasette/templates/_table.html b/datasette/templates/_table.html index a1329ba7..ba34b60f 100644 --- a/datasette/templates/_table.html +++ b/datasette/templates/_table.html @@ -6,7 +6,7 @@ {% for column in display_columns %} - + {% if not column.sortable %} {{ column.name }} {% else %} diff --git a/datasette/views/table.py b/datasette/views/table.py index 035abb1b..cf5b5b64 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -369,6 +369,7 @@ async def display_columns_and_rows( "is_pk": False, "type": "", "notnull": 0, + "is_special_link_column": True, } columns = [first_column] + columns return columns, cell_rows diff --git a/tests/test_table_html.py b/tests/test_table_html.py index a39df25d..d8dde593 100644 --- a/tests/test_table_html.py +++ b/tests/test_table_html.py @@ -248,6 +248,7 @@ async def test_sort_links(ds_client): "data-column-type": "", "data-column-not-null": "0", "data-is-pk": "0", + "data-is-link-column": "1", }, "a_href": None, },