Skip to content

Commit

Permalink
remove debug
Browse files Browse the repository at this point in the history
  • Loading branch information
christinaroise committed Sep 23, 2024
1 parent bd9efed commit 22814d8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions studio/components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const LanguageSelector = ({ value = [], onChange }: LanguageSelectorProps) => {

// Get the currently set default language
const currentDefaultLanguage = value.find((lang) => lang.default)?.id || null;
console.log(currentDefaultLanguage);

const handleLanguageSelection = (lang: Language) => {
const isSelected = value.some((item) => item.id === lang.id);
Expand All @@ -46,7 +45,7 @@ const LanguageSelector = ({ value = [], onChange }: LanguageSelectorProps) => {
const newDefaultLanguage = getNewDefaultLanguage(
updatedValue,
currentDefaultLanguage,
lang,
lang
);

const finalValue = updatedValue.map((item) => ({
Expand Down Expand Up @@ -131,17 +130,17 @@ const LanguageSelector = ({ value = [], onChange }: LanguageSelectorProps) => {
const getNewDefaultLanguage = (
updatedLanguages: Language[],
currentDefault: string | null,
deselectedLang: Language,
deselectedLang: Language
): string | null => {
if (updatedLanguages.length === 1) {
return updatedLanguages[0].id; // Only one language left
return updatedLanguages[0].id;
}

if (currentDefault === deselectedLang.id) {
// Find a new default language if the current default is deselected
return (
supportedLanguages.find((lang) =>
updatedLanguages.some((item) => item.id === lang.id),
updatedLanguages.some((item) => item.id === lang.id)
)?.id || null
);
}
Expand Down

0 comments on commit 22814d8

Please sign in to comment.