Skip to content

Commit

Permalink
feat(FormationsSelector): keep focus on multiselect
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanngab committed Oct 30, 2024
1 parent 1a34de2 commit 69a1082
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ui/src/campagnes/CreateCampagnes/FormationsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BeatLoader from "react-spinners/BeatLoader";
import { DIPLOME_TYPE_MATCHER, USER_ROLES, VIEW_TYPES } from "../../constants";
import { UserContext } from "../../context/UserContext";
import useFetchCampagnes from "../../hooks/useFetchCampagnes";
import useFetchDiplomesWithCampagnesCount from "../../hooks/useFetchDiplomesWithCampagnesCount";
import useFetchDiplomesAndEtablissementsFilter from "../../hooks/useFetchDiplomesAndEtablissementsFilter";
import useFetchRemoteFormations from "../../hooks/useFetchRemoteFormations";
import { remoteEtablissementLabelGetterFromFormation } from "../../utils/etablissement";
import FilterButtons from "../Shared/FilterButtons/FilterButtons";
Expand Down Expand Up @@ -114,7 +114,7 @@ const FormationsSelector = ({ selectedFormations, setSelectedFormations }) => {
diplomesFilter,
etablissementsFilter,
isSuccess: isSuccessDiplomesAndEtablissementsFilter,
} = useFetchDiplomesWithCampagnesCount();
} = useFetchDiplomesAndEtablissementsFilter();

const {
campagnes: campagnes,
Expand Down Expand Up @@ -185,7 +185,7 @@ const FormationsSelector = ({ selectedFormations, setSelectedFormations }) => {
/>
)}
<>
{isSuccessFormations && (
{isSuccessDiplomesAndEtablissementsFilter && (
<>
<FilterButtons
search={search}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "../../../constants";
import { UserContext } from "../../../context/UserContext";
import useFetchCampagnes from "../../../hooks/useFetchCampagnes";
import useFetchDiplomesWithCampagnesCount from "../../../hooks/useFetchDiplomesWithCampagnesCount";
import useFetchDiplomesAndEtablissementsFilter from "../../../hooks/useFetchDiplomesAndEtablissementsFilter";
import { etablissementLabelGetterFromFormation } from "../../../utils/etablissement";
import ActionButtons from "../../ManageCampagne/ActionButtons/ActionButtons";
import { ButtonContainer } from "../../styles/resultsCampagnes.style";
Expand Down Expand Up @@ -62,7 +62,7 @@ const CampagnesSelector = ({
diplomesFilter,
etablissementsFilter,
isSuccess: isSuccessDiplomesAndEtablissementsFilter,
} = useFetchDiplomesWithCampagnesCount();
} = useFetchDiplomesAndEtablissementsFilter();

const currentPageCampagneIds = campagnes?.map((campagne) => campagne.id);

Expand Down
4 changes: 2 additions & 2 deletions ui/src/campagnes/Shared/FilterButtons/FilterButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ const FilterButtons = ({
}, [inputValue, setSearch, setIsOpened]);

useEffect(() => {
if (!selectedEtablissementsSiret) {
if (!selectedEtablissementsSiret?.length) {
setSelectedEtablissementsSiret(etablissementsOptions.map((option) => option.value));
}
}, [selectedEtablissementsSiret, etablissementsOptions]);

useEffect(() => {
if (!selectedDiplomesIntitule) {
if (!selectedDiplomesIntitule?.length) {
setSelectedDiplomesIntitule(diplomesOptions.map((option) => option.value));
}
}, [diplomesOptions]);
Expand Down

0 comments on commit 69a1082

Please sign in to comment.