mirror of
https://github.com/simonw/datasette.git
synced 2026-10-18 15:26:57 +02:00
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:
parent
cf113a5985
commit
69cfd16fcf
2 changed files with 15 additions and 2 deletions
|
|
@ -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
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue