Skip to content

Let authors choose which columns a filterable table offers as dropdowns - #4915

Open
nastasha-solomon wants to merge 8 commits into
mainfrom
filterable-table-column-control
Open

nastasha-solomon wants to merge 8 commits into
mainfrom
filterable-table-column-control

Conversation

@nastasha-solomon

@nastasha-solomon nastasha-solomon commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #4914.

Summary

Writers can already add a search box and filter dropdowns to a table with the :filterable: option. Today, docs-builder decides on its own which columns get a dropdown. This PR lets the writer make that choice, with two new options:

  • :filterable: search shows the search box and nothing else.
  • :filter-columns: names the columns that get a dropdown. No other column gets one.

Tables that already use :filterable: work exactly as they do today. The one visible change is the arrow on each filter dropdown, which now sits inset from the border instead of against it. The controls above filterable tables are reworked separately in #4920, which is stacked on this PR.

The problem

docs-builder adds a dropdown to every column that has between 2 and 12 different values. That's right for a column like Type or Status. It's wrong for a column of scores, which also has only a few different values.

The Security LLM performance matrix (elastic/docs-content#9483) shows the problem. Each row is a model, and most columns are scores from 1 to 10. The table gets seven score dropdowns, stacked in four rows above the table. Each dropdown matches one exact score, such as "9.00". A reader comparing models doesn't filter that way, and the writer had no way to remove them.

1-before-auto-dropdowns

Option 1: a search box with no dropdowns

Add search after :filterable::

:::{table}
:filterable: search

Readers get the search box and the "Showing N of M" count. Typing narrows the table to the rows that contain the text, in any column.

Before typing After typing "sonnet"
2-search-only 3-search-only-typed-sonnet

Option 2: choose which columns get a dropdown

List the columns by their header text, separated by commas:

:::{table}
:filterable:
:filter-columns: Provider

Only the listed columns get a dropdown. In this example, the writer also split the model name into Provider and Model columns, so readers can compare one provider's models.

Before choosing After choosing OpenAI
4-filter-columns-provider 5-filter-columns-provider-openai

This recording shows the Provider dropdown and the search box working together:

6-filter-columns-provider-demo.webm

A few details about matching column names:

  • Names match the header text readers see. Capital letters, extra spaces, bold or italic text, and footnote markers don't matter, so support status matches a Support status header.
  • A header that uses a variable, such as {{es}} version, matches the variable's value. You write Elasticsearch version.
  • A listed column gets a dropdown even if it has more than 12 different values.
  • A listed column with only one value gets no dropdown, because there's nothing to choose between.

Mistakes the build catches

If the table has The build reports
A :filter-columns: name that matches no column header An error that lists the column headers you can use
Any value for :filterable: other than search, true, or false An error
:filter-columns: without :filterable: A warning, and the table gets no filters
Both :filterable: search and :filter-columns: An error, because the two options conflict

Before this change, a value like :filterable: yes turned filtering off without any message. It's now an error. No page in docs-content uses a value with :filterable:, so nothing breaks.

Try it

The docs preview for this PR has working examples of both options under Choose which columns get dropdown filters:
https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4915/syntax/tables#choose-which-columns-get-dropdown-filters

How the screenshots were made

The screenshots and recording use the live preview of elastic/docs-content#9483, with its real styles and data. The new filter code from this branch replaces the old code on the page. For Option 2, a script also split the Model column into Provider and Model to stand in for the docs-content change a writer would make.

Technical details for reviewers

Server side

  • TableDirectiveBlock reads :filterable: itself instead of through PropBool, which treated any value other than true as false. It accepts no value, true, false, or search.
  • :filterable: search renders <filterable-table data-facets="none">.
  • :filter-columns: A, B is matched against the header row at render time, next to the existing column-width check, because Markdig turns the paragraph into a table only after the directive closes. The build renders the matched columns' zero-based positions, such as <filterable-table data-facet-columns="1,2">, so header text is compared only on the server.
  • Header text is what readers see. Substitutions use their value, including mutations, HTML entities are decoded, footnote markers are skipped, and whitespace is collapsed in both the header and the name. A role in a header keeps its raw content, which can differ from what it renders. That case is rare, so it's left as is.

Client side

  • FilterableTable.ts reads the two data attributes. With data-facets="none" it builds no dropdowns. With data-facet-columns it builds dropdowns only for the columns at the listed positions, and skips the 12-value cap and the key-column check for them.
  • Fullscreen clones the host element, so the clone keeps the data attributes and builds the same dropdowns.

CSS

  • The filter dropdowns use appearance: none and draw a thin chevron with two linear-gradient lines in currentColor, inset from the right edge, with extra right padding so the value stays clear of it. Using the text color means it follows the design system's light and dark themes. The change is in both Assets/markdown/table.css and the design-system Components/Markdown/Table/table.css.

Tests

cd src/Elastic.Documentation.Site && npx vitest run Assets/web-components/FilterableTable.test.ts

Eight new tests, under "filterable-table author-chosen dropdowns", cover the default behavior, search only, listed columns, table order, a key column, the lifted cap, a header with a footnote and extra spaces, and a position that isn't a number.

dotnet test tests/Elastic.Markdown.Tests/ --filter "FullyQualifiedName~TableDirective"

Nine new test classes cover search only, the unknown-column error, case and emphasis matching, headers with a footnote, a substitution, or extra spaces, an invalid value, a missing :filterable:, and the conflicting options.

The vitest suite, tsc, ESLint, Prettier, and curb check pass locally. The C# tests weren't run locally, because this machine has .NET SDK 10 and global.json requires 11.

🤖 Generated with Claude Code

`:filterable:` offers a dropdown for every column with 2 to 12 distinct
values. Columns of scores or counts qualify, so a table like the Security
LLM performance matrix gets a stack of exact-match score dropdowns.

`:filterable: search` keeps the search box and count without dropdowns.
`:filter-columns:` names the columns that get one, matched by header text,
and skips the distinct-value cap and key-column check for those columns.
An unknown column name is a build error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nastasha-solomon and others added 2 commits November 17, 2026 18:30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4915/

Sample changed pages:

The build and the browser each worked out header text, in different ways,
so a header could pass the build check and still get no dropdown, or fail
the check while matching what readers see.

The build now matches :filter-columns: names against the text readers see
(substitution values, decoded entities, no footnote markers, collapsed
whitespace) and renders the matched column positions. The browser filters
by position and never compares header text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser's own arrow on the filter dropdowns sat against the right
border, so it looked like it was falling out of the control. The
dropdowns now hide the native arrow and draw a thin chevron inset from
the edge, with padding to keep the value clear of it. It's drawn in the
text color, so it follows the design system's dark themes too. Both the
legacy and the design-system stylesheets get the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nastasha-solomon

Copy link
Copy Markdown
Member Author

This PR is part of a group of related table improvements:

PR Issue What it adds Base
#4915 #4914 :filterable: search, :filter-columns:, the inset dropdown arrow main
#4918 #4917 :pin-first-column: main
#4920 #4919 Easier filter controls #4915
#4922 #4921 Filterable prebuilt rules table #4915

Forced-colors mode (Windows High Contrast) drops gradient background
images, so the drawn chevron vanished and the filter dropdowns looked
like plain text boxes. In that mode the dropdowns now go back to the
browser's own arrow and padding, in both stylesheets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
assembler-preview — 7599a6cc Deployed Nov 18, 2026 by github-actions[bot]
docs-preview — 7599a6cc Deployed Nov 18, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let authors choose which columns get dropdowns in a :filterable: table

1 participant