fix(media): named search input + grid-only fragment for media selector#893
Open
PlusA2M wants to merge 1 commit into
Open
fix(media): named search input + grid-only fragment for media selector#893PlusA2M wants to merge 1 commit into
PlusA2M wants to merge 1 commit into
Conversation
GET /admin/media/selector had two defects: the search input had an `id` but no `name`, so `hx-include="[name='search']"` never sent the term; and the endpoint always returned the full panel (search box + grid), while the input targets the inner `#media-selector-grid` — so each keystroke swapped a whole new panel into the grid, nesting one per keystroke. Add `name="search"` to the input and return a grid-only fragment for the HTMX search request (HX-Target: media-selector-grid), keeping the full panel for the initial modal load. Also re-query on the search input's native clear button. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: PlusA2M <plusa2m@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The "Select Media" picker's search was broken two ways: the input had no
name(so
hx-include="[name='search']"sent nothing), and the endpoint always returnedthe full panel into the inner grid (so each keystroke nested a fresh search box +
grid). This makes search filter in place without nesting.
Fixes #890
Changes
admin-media.tsGET /selector: addname="search"to the input so the termis actually sent.
(
HX-Target: media-selector-grid), and the full panel only on the initialmodal load — so keystrokes update the grid in place instead of nesting a panel.
inside the grid (
col-span-full).hx-trigger … , search).returns only cards (no
<input>, no grid container) with the term bound; emptysearch renders the in-grid empty state.
Testing
Unit Tests
admin-media-selector.test.ts)npm test— full suite green)E2E Tests
Checklist