feat(web): search album description in add-to-album modal (#30462)

Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
This commit is contained in:
Gueye Papa Djadji 2026-08-03 10:42:44 +00:00 committed by GitHub
parent 4082fbf232
commit da7d8c2e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 1 deletions

View file

@ -40,6 +40,9 @@
const albumNameArray: string[] = $derived.by(() => {
let { albumName } = album;
let findIndex = normalizeSearchString(albumName).indexOf(normalizeSearchString(searchQuery));
if (findIndex === -1) {
return [albumName, '', ''];
}
let findLength = searchQuery.length;
return [
albumName.slice(0, findIndex),

View file

@ -108,6 +108,19 @@ describe('Album Modal', () => {
]);
});
it('search matches on description as well as name', () => {
const converter = new AlbumModalRowConverter(AlbumSortBy.MostRecentPhoto, SortOrder.Desc);
const holidayAlbum = albumFactory.build({ albumName: 'Vacances 2019', description: 'Crete' });
const constructionAlbum = albumFactory.build({ albumName: 'Construction' });
const modalRows = converter.toModalRows('Crete', [], [holidayAlbum, constructionAlbum], -1, []);
expect(modalRows).toStrictEqual([
createNewAlbumRow(false),
createSectionRow('ALBUMS'),
createAlbumRow(holidayAlbum, false),
]);
});
it('selection can select new album row', () => {
const converter = new AlbumModalRowConverter(AlbumSortBy.MostRecentPhoto, SortOrder.Desc);
const holidayAlbum = albumFactory.build({ albumName: 'Holidays' });

View file

@ -46,10 +46,14 @@ export class AlbumModalRowConverter {
const recentAlbumsToShow = search.length === 0 ? recentAlbums : [];
const rows: AlbumModalRow[] = [{ type: AlbumModalRowType.NEW_ALBUM, selected: selectedRowIndex === 0 }];
const normalizedSearch = normalizeSearchString(search);
const filteredAlbums = sortAlbums(
search.length > 0 && albums.length > 0
? albums.filter((album) => {
return normalizeSearchString(album.albumName).includes(normalizeSearchString(search));
return (
normalizeSearchString(album.albumName).includes(normalizedSearch) ||
normalizeSearchString(album.description).includes(normalizedSearch)
);
})
: albums,
{ sortBy: this.sortBy, orderBy: this.orderBy },