Skip to content

Commit

Permalink
fixed react-select losing focus on clear, NafAutocomplete default values
Browse files Browse the repository at this point in the history
  • Loading branch information
enguerranws committed Feb 4, 2025
1 parent 20f6e1d commit 4ca7548
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions front/src/app/pages/search/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ export const SearchPage = ({
: formValues.nafLabel,
]
: [];
return [...appellationDisplayed, ...nafDisplayed].join(" - ");
return appellationDisplayed.length || nafDisplayed.length
? [...appellationDisplayed, ...nafDisplayed].join(" - ")
: "Tous les métiers";
};
return (
<HeaderFooterLayout>
Expand Down Expand Up @@ -419,7 +421,7 @@ export const SearchPage = ({
});
}}
className={fr.cx("fr-mt-2w")}
initialInputValue={"initial value"}
initialInputValue={formValues.nafLabel}
/>
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export const SearchFilter = ({
const hasValue = values && values.length > 0;
const wrapperElement = useRef<ElementRef<"div">>(null);
useLayoutEffect(() => {
if (isOpened && wrapperElement.current) {
if (
isOpened &&
wrapperElement.current &&
wrapperElement.current.querySelectorAll(".im-select__control--is-focused")
.length === 0
) {
wrapperElement.current.querySelector("input")?.focus();
}
document.body.addEventListener("click", handleClickOutside);
Expand Down

0 comments on commit 4ca7548

Please sign in to comment.