Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOC]MWPW-165589 - Deselect languages when there are no respective locales selected #3563

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: added useCallback to put function as dependency in useEffect
  • Loading branch information
saurabhsircar11 committed Jan 29, 2025
commit c9b2526725ecefe8d43563a109223609c6101d73
8 changes: 4 additions & 4 deletions libs/blocks/locui-create/input-locale/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from '../../../deps/htm-preact.js';
import { useState, useEffect, useCallback } from '../../../deps/htm-preact.js';
import {
nextStep,
prevStep,
Expand Down Expand Up @@ -171,15 +171,15 @@ export default function useInputLocale() {
removeLocalesFromActive(regionCountryCodes);
};

const updateRegionStates = (localeList) => {
const updateRegionStates = useCallback((localeList) => {
const updatedRegionStates = {};
localeRegionList.forEach((region) => {
const regionLocales = region.value.split(',');
const isRegionActive = regionLocales.every((locale) => localeList.includes(locale));
updatedRegionStates[region.key] = isRegionActive;
});
return updatedRegionStates;
};
}, [localeRegionList]);

const selectAll = () => {
const allRegions = {};
Expand Down Expand Up @@ -211,7 +211,7 @@ export default function useInputLocale() {
...prevState,
...updateRegionStates(selectedLocale),
}));
}, [selectedLocale]);
}, [selectedLocale, updateRegionStates]);

const errorPresent = () => Object.keys(activeLocales).length > 0;

Expand Down
Loading