From b0407867cc433e75bb6931f5999dceb306aa97c3 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 15 Sep 2026 10:16:16 -0700 Subject: [PATCH] Tweak display of count all button, refs #2914 --- datasette/static/app.css | 12 ++++++++++++ datasette/templates/table.html | 4 ++-- tests/test_plugins.py | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/datasette/static/app.css b/datasette/static/app.css index f7e6c24f..234f535c 100644 --- a/datasette/static/app.css +++ b/datasette/static/app.css @@ -216,6 +216,18 @@ a:active { text-decoration: underline; } +.table-summary .count-all ~ .table-summary-description { + margin-left: 0.5rem; +} + +.table-summary .count-error:not(:empty) { + display: block; + margin-top: 0.25rem; + font-size: 0.875rem; + font-weight: 400; + line-height: 1.5; +} + button.count-all { background: none; border: none; diff --git a/datasette/templates/table.html b/datasette/templates/table.html index e8d8ae65..3ce88e35 100644 --- a/datasette/templates/table.html +++ b/datasette/templates/table.html @@ -47,12 +47,12 @@ {% endif %} {% if count or human_description_en %} -

+

{% if count_truncated %}{{ "{:,}".format(count - 1) }}+ rows {% elif count or count == 0 %}{{ "{:,}".format(count) }} row{% if count == 1 %}{% else %}s{% endif %}{% endif %} - {% if human_description_en %}{{ human_description_en }}{% endif %} + {% if human_description_en %}{{ human_description_en }}{% endif %}

{% endif %} diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 734f0fc2..390a40f6 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -1300,7 +1300,8 @@ async def test_hook_filters_from_request(ds_client): ds_client.ds.pm.register(ReturnNothingPlugin(), name="ReturnNothingPlugin") response = await ds_client.get("/fixtures/facetable?_nothing=1") - assert "0 rows\n where NOTHING" in response.text + summary = Soup(response.text, "html.parser").select_one(".table-summary") + assert summary.get_text(" ", strip=True) == "0 rows where NOTHING" json_response = await ds_client.get("/fixtures/facetable.json?_nothing=1") assert json_response.json()["rows"] == [] ds_client.ds.pm.unregister(name="ReturnNothingPlugin")