Offer "Facet by this" for the first column of a view

The column menu skipped the facet option for whichever column came
first, which was meant to skip the special link column on tables.
Views have no link column, so their first real column lost the option.
Check data-is-link-column instead.

Closes #1785
This commit is contained in:
Daniel Shafer 2026-10-06 14:30:08 +00:00
commit 69cfd16fcf
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View file

@ -370,7 +370,7 @@ function buildColumnActionItems(manager, th, options) {
var column = th.dataset.column;
var columnActions = [];
var isSortable = !!th.querySelector("a");
var isFirstColumn = th.parentElement.querySelector("th:first-of-type") === th;
var isLinkColumn = th.dataset.isLinkColumn === "1";
var isSinglePk =
th.dataset.isPk === "1" &&
document.querySelectorAll('th[data-is-pk="1"]').length === 1;
@ -394,7 +394,7 @@ function buildColumnActionItems(manager, th, options) {
if (
DATASETTE_ALLOW_FACET &&
!isFirstColumn &&
!isLinkColumn &&
!getDisplayedFacets().includes(column) &&
!isSinglePk
) {

View file

@ -2301,3 +2301,16 @@ def test_menu_long_plugin_content_and_no_popover_fallback(page, datasette_server
assert panel.evaluate("node => node.scrollTop > 0")
page.keyboard.press("Escape")
expect(panel).not_to_be_visible()
@pytest.mark.playwright
def test_column_menu_facet_by_first_column_of_view(page, datasette_server):
# https://github.com/simonw/datasette/issues/1785
from playwright.sync_api import expect
panel = page.locator("#column-actions-menu")
page.goto(datasette_server + "fixtures/paginated_view")
page.locator('th[data-column="content"] .column-menu-trigger').click()
expect(
panel.get_by_role("menuitem", name="Facet by this", exact=True)
).to_be_visible()