Skip to content

feat(EasyAdmin): Add search bar in media library #131

Open
loic425 wants to merge 2 commits into
jolicode:mainfrom
loic425:feat-easy-admin/search-bar-in-media-library
Open

feat(EasyAdmin): Add search bar in media library #131
loic425 wants to merge 2 commits into
jolicode:mainfrom
loic425:feat-easy-admin/search-bar-in-media-library

Conversation

@loic425
Copy link
Copy Markdown
Contributor

@loic425 loic425 commented May 22, 2026

Based on #128

@loic425 loic425 changed the title Feat easy admin/search bar in media library feat(EasyAdmin): Add search bar in media library May 22, 2026
@loic425 loic425 force-pushed the feat-easy-admin/search-bar-in-media-library branch from c539a04 to 9a4f1e3 Compare May 22, 2026 13:22
@damienalexandre damienalexandre requested a review from Copilot May 26, 2026 13:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds search capability to the EasyAdmin media library UI (including the media chooser modal) by introducing search inputs in Twig templates and applying server-side filtering in the EasyAdmin MediaAdminController.

Changes:

  • Add translated labels for the new search UI (EN/FR).
  • Add search UI in the media library templates (explore header + chooser modal list).
  • Implement query-driven filtering (directories + medias) in the EasyAdmin media list controller and update frontend JS assets.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/Bridge/EasyAdmin/translations/JoliMediaEasyAdminBundle.fr.yaml Adds FR strings for search button/placeholder.
src/Bridge/EasyAdmin/translations/JoliMediaEasyAdminBundle.en.yaml Adds EN strings for search button/placeholder.
src/Bridge/EasyAdmin/templates/list.html.twig Adds chooser-modal search bar above the gallery list/grid.
src/Bridge/EasyAdmin/templates/explore.html.twig Adds a search form next to breadcrumbs in the explore header.
src/Bridge/EasyAdmin/src/Controller/MediaAdminController.php Reads query and filters directory/media listings; passes search value to Twig.
src/Bridge/EasyAdmin/public/manifest.json Updates built asset hash reference.
src/Bridge/EasyAdmin/public/joli-media-easy-admin.51f41996.js Updates built JS bundle (includes search behavior).
src/Bridge/EasyAdmin/public/entrypoints.json Updates built asset hash reference.
src/Bridge/EasyAdmin/assets/js/components/mediaSelector.js Adds chooser-modal search behavior (fetching filtered folder views).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +20 to +24
const getSearchUrl = (baseUrl) => {
if (!currentSearchValue) return baseUrl;
const separator = baseUrl.includes('?') ? '&' : '?';
return `${baseUrl}${separator}search=${encodeURIComponent(currentSearchValue)}`;
};
Comment on lines +273 to +275
$searchValue = $request->query->getString('query', '');
$hasSearch = '' !== $searchValue;

Comment on lines +12 to +21
{% if 'choose' in base_template %}
<div class="joli-media-search mb-3">
<form class="joli-media-search-form" data-component="media-search">
<div class="input-group">
<input type="search" class="form-control joli-media-search-input" placeholder="{{ 'media.search_label'|trans }}" value="{{ search }}" autocomplete="off">
<button class="btn btn-outline-secondary joli-media-search-btn" type="submit"><i class="fas fa-search"></i> {{ 'action.search'|trans }}</button>
</div>
</form>
</div>
{% endif %}
Comment on lines +61 to +66
newInput.addEventListener('search', () => {
if (!newInput.value) {
currentSearchValue = '';
fetchFolder(currentFolderUrl).then(configureModal);
}
});
Comment on lines 321 to 325
$paginatedMedias = $this->getOriginalStorage()->listMediasPaginated(
$currentKey,
recursive: false,
recursive: $hasSearch,
page: $request->query->getInt('page', 1),
perPage: $this->config->getPaginationSize(),
Comment on lines +273 to 277
$searchValue = $request->query->getString('query', '');
$hasSearch = '' !== $searchValue;

try {
$trashPath = $this->getOriginalStorage()->getTrashPath();
Comment on lines +315 to +318
$mediaFilter = null;
if ($hasSearch) {
$mediaFilter = static fn ($media): bool => str_contains(strtolower($media->getPath()), strtolower($searchValue));
}
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