Skip to content

Add search to Builder block picker - #20469

Open
KianAcquoy wants to merge 6 commits into
filamentphp:4.xfrom
KianAcquoy:feature/searchable-block-picker
Open

Add search to Builder block picker#20469
KianAcquoy wants to merge 6 commits into
filamentphp:4.xfrom
KianAcquoy:feature/searchable-block-picker

Conversation

@KianAcquoy

Copy link
Copy Markdown
Contributor

Description

Adds an opt-in search field to the Builder block picker, to quickly filter large block lists. It reuses the CanBeSearchable concern from CheckboxList, so searchPrompt(), noSearchResultsMessage() and searchDebounce() are also supported. The field is auto-focused when the picker opens, using a new reactive isOpen property on the shared dropdown Alpine component.

Builder::make('content')
    ->searchable()
    ->blocks([
        // ...
    ])

Visual changes

Without searchable
image

With searchable
image
image

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin danharrin added enhancement New feature or request pending review labels Sep 8, 2026
@danharrin danharrin added this to the v4 milestone Sep 8, 2026

@danharrin danharrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! A few things need addressing before we merge:

  • Please keep the search labels in sync when the available blocks change, for example when a block reaches maxItems(). Alpine currently retains the original labels array after a Livewire morph, so searches can hide the wrong blocks.
  • Escape currently closes the picker as well as clearing the search. The dropdown handles Escape before the input’s stopPropagation(). Please make the first Escape clear a nonempty search, then close on the next Escape and return focus to the trigger.
  • Please search HTML labels as they appear to the user. Stripping tags leaves entities encoded, so a label displaying R&D doesn’t match a search for R&D.
  • Please add tests for the new configuration and browser behavior, including changing available blocks, keyboard interaction, and accessibility checks in light and dark modes.
  • Please define the supported search configuration directly on Builder rather than using CanBeSearchable. That concern also exposes methods such as searchValues() and searchLabels() which have no effect here.

@KianAcquoy

Copy link
Copy Markdown
Contributor Author

Thank for the feedback, Dan. I've addressed all points in my latest commit.

While moving off CanBeSearchable I noticed CheckboxList has the same issue: it uses the concern but never reads searchingMessage(), noOptionsMessage(), searchLabels() or searchValues(). Maybe we should resolve that in a follow-up PR?

@danharrin

Copy link
Copy Markdown
Member

Yeah a follow up PR would be good thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pending changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants