Skip to content

Commit 86b8cb5

Browse files
committed
fix(content_management): ensure source language selection is correctly displayed
- Update logic to find the correct language object from the full list - Modify DropdownButton selection logic to use reference equality - Preserve initial selection when the source already contains a language
1 parent af30ff2 commit 86b8cb5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/content_management/bloc/edit_source/edit_source_bloc.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
6161
final countries = (countriesResponse as PaginatedResponse<Country>).items;
6262
final languages = (languagesResponse as PaginatedResponse<Language>).items;
6363

64+
// The source contains a Language object. We need to find the equivalent
65+
// object in the full list of languages to ensure the DropdownButton
66+
// can correctly identify and display the initial selection by reference.
6467
final selectedLanguage = languages.firstWhere(
65-
(l) => l.code == source.language,
66-
orElse: () => const Language(name: '', code: ''),
68+
(listLanguage) => listLanguage == source.language,
69+
orElse: () => source.language,
6770
);
6871

6972
emit(

0 commit comments

Comments
 (0)