From f3905e9045ab6ff2d7182d996250d26cedcab5fe Mon Sep 17 00:00:00 2001 From: christinaroise Date: Wed, 25 Sep 2024 10:10:05 +0200 Subject: [PATCH] update comments --- studio/components/LanguageSelector.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/studio/components/LanguageSelector.tsx b/studio/components/LanguageSelector.tsx index feb583dab..c42fff384 100644 --- a/studio/components/LanguageSelector.tsx +++ b/studio/components/LanguageSelector.tsx @@ -32,9 +32,8 @@ const LanguageSelector = ({ const handleLanguageSelection = (lang: Language, isSelected: boolean) => { let updatedValue: Language[]; - // Handle deselection of a language if (isSelected) { - // Remove the deselected language from the current value + // Deselect the language updatedValue = value.filter((item) => item.id !== lang.id); // If the deselected language is the current default @@ -44,7 +43,7 @@ const LanguageSelector = ({ (language) => language.id === lang.id, ); - // Attempt to find the next selected language after the deselected one + // Get the next selected language in the supportedLanguages order const nextDefaultLanguage = supportedLanguages .slice(indexInSupported + 1) // Get languages after the deselected one @@ -52,6 +51,7 @@ const LanguageSelector = ({ updatedValue.some((item) => item.id === language.id), ) || updatedValue[0]; // Fallback to the first selected language if none found + // Set the new default if there's a next selected language updatedValue = updatedValue.map((item) => ({ ...item, default: item.id === nextDefaultLanguage.id,