Install
Works with Drupal: ^10.3 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
Search Web Components 1.0.0-beta1 is the first beta of the 1.0 line. The 1.0 API is complete and documented, every site on 1.0.0-alpha6 has an upgrade path, and the beta is out so sites can test both before 1.0.0. A beta can still change before 1.0.0; report what breaks or reads wrong in the issue queue. The Drupal module and the npm package drupal-search-web-components release together and share a version. For every component, setting, and hook, see the documentation; for every change, the changelog.
Before you update
- Update search_api_decoupled to 1.0.0-alpha44 or later; the module requires it.
- Update the Drupal module before the npm package, and clear cached endpoint responses.
- Enable Search Web Components: Facets if Blocks is enabled without it. Blocks now depends on it.
- Run the database updates, export the configuration, and rebuild caches. The post updates convert endpoint page sizes, sort options, and the option blocks' settings. Each is safe to run again, and its message names what to check.
- Read "What changes for every site" below.
What's new
- Searching another API.
search-roothas request hooks to build the request, send it, and map the response, so a subclass searches any Drupal site's endpoint or an API that is not Drupal. Searching another API - Drupal Canvas and Twig. Every component is a single directory component, with two Canvas layout components and a Canvas submodule that adds a facet picker, an endpoint picker, and row editing for sort options. Drupal Canvas, Twig
- Sort options with an alias and a default. The page URL reads
?sort=newest, the endpoint form edits sort options, page sizes, listing layouts, and result elements in place, and a sort option can have tie-breakers. Endpoint settings - Accessibility. Every control has an accessible name, set by an attribute and a block or layout setting; each search is announced to screen readers; focus stays in place after a search; the HTML dropdown follows the W3C combobox pattern; the modal filter dialog keeps focus inside. Accessibility
- New components and settings. A loading indicator with
showOnFirstLoad,keepFilterson the search input, an applied count on the dialog toggle, facets that keep one applied value at a time, andfacet-buttonrendering hierarchy children. - A site script can subclass a component with no build step.
window.SearchWebComponentsholds every class and Lit's template helpers. A subclass on a Drupal page - Documentation and Storybook. A getting started guide for Layout Builder and one for Drupal Canvas, a developer guide, and a Storybook page per component with a story for each attribute, its events, classes, ARIA attributes, hooks, and methods. Storybook
What changes for every site
- Theme overrides of the blocks stop applying. The
swc_*theme hooks andswc-*.html.twigtemplates are gone; the blocks render single directory components. The status report lists the overrides that no longer apply. A template becomes a theme component withreplaces:; a preprocess becomeshook_preprocess_block()changing the component's props. Customizing in Drupal code - The filter dialog opens only below 768 px on a root the module renders without an explicit
dialogBreakpoint. Pass-1from Twig or Canvas to keep a dialog at every width. The two-column layout stacks its columns below 40em. - Sort options have an alias and a default. The post update gives each option an alias and makes the option that sorted the way the endpoint already did the default. When none matches, it adds an option for that sort as the default and names the endpoint; rename the option on the endpoint form.
- Page sizes live in the endpoint's Items per page options. The post update moves them. A page whose layout sets a different default size now starts with that size.
- The first save of an endpoint form after updating is refused until Limit is one of the page sizes, no two result elements share a key, no key or size repeats, and exactly one sort option is the default.
- Block options are rows, not text. The post updates convert the sort, page size, listing layout, and results blocks.
- A facet created on an endpoint starts with the Checkbox widget, and the facet form of an endpoint facet shows only Search Web Components widgets.
- New markup for assistive technology, listed per element in Storybook:
role="search"on the search forms,role="group"andaria-labelon the facet, sort, page size, and switcher elements,role="navigation"on the pager, and a status region appended tobody. Every name and announcement is a setting. - Spellcheck and Canvas are experimental submodules. Their settings and behaviour can change in a minor release.
If you customized the module or the elements
A FacetBlockBase subclass, a custom event subscriber, a script on the swc-* events, a subclass of an element, or a deep import of the npm package: the changelog's "If you customized" section lists each change with what to do, in Drupal code and in the elements and the npm package.
Fixes
- The
dist/modules import each other with the.jsextension, so the package loads through an import map, in Node, and with webpack 5. - Numeric response keys sent as strings are read as numbers.
- A request with only
sortor onlyorderis completed from the endpoint's default, sosearch-sorthighlights the option in use. - The Facets submodule runs the facet query types once per request and declares each facet as a cache dependency of the response.
- The two-column layout's 15/85, 85/15, 20/80, and 80/20 widths split the row as named.
Known issues
- The Spellcheck submodule still needs the search_api_spellcheck patch named in its README.
- The test suite does not run on PHPUnit 12 yet, so the beta is untested on Drupal 12.