Skip to content

Allow opt-in HTML option labels in SearchableInput - #37

Merged
fabio-ivona merged 1 commit into
defstudio:mainfrom
BenjaminRayner:feature/html-option-labels
Nov 2, 2026
Merged

fabio-ivona merged 1 commit into
defstudio:mainfrom
BenjaminRayner:feature/html-option-labels

Conversation

@BenjaminRayner

Copy link
Copy Markdown
Contributor

SearchableInput currently renders all suggestion labels with Alpine's x-text, so labels such as <strong>EA</strong> Each display their markup literally.

Add opt-in ->allowHtml() support using Filament's existing CanAllowHtml concern. The dropdown uses x-html only when enabled; plain text remains the default. Boolean and closure conditions are supported. Option values, custom search results, and selection behavior remain unchanged.

SearchableInput::make('StockUom')
    ->allowHtml()
    ->options([
        'EA' => '<strong>EA</strong> Each',
        'FT' => '<strong>FT</strong> Feet',
    ]);

Update the README with usage and guidance to use trusted or sanitized HTML labels.

Validation: php vendor/bin/pest tests/SearchableInputTest.php --compact — 7 passed, 12 assertions, on PHP 8.5 with Filament 5.11.0. Covers default/explicitly disabled text rendering, enabled HTML rendering, closure conditions, and preserving values and metadata for static/custom results. git diff --check passed. Browser interaction was not tested.

@fabio-ivona
fabio-ivona merged commit 7126cf2 into defstudio:main Nov 2, 2026
1 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants