Skip to content

Commit

Permalink
Legg inn kommentar om hvorfor vi bruker option ref ved endring av kom…
Browse files Browse the repository at this point in the history
…boboks for janzz
  • Loading branch information
joarau committed Nov 8, 2024
1 parent ff6db80 commit a99766d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stilling/stilling/edit/om-stillingen/janzz/Janzz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Janzz: FunctionComponent<Props> = ({ tittel }) => {
const [input, setInput] = useState<string>(tittel);
const [hasValidSelection, setHasValidSelection] = useState<boolean>(true);

// Må håndtere at onChange blir kalt når en onToggleSelection blir valgt i comboboxen
const optionSelectedRef = useRef<boolean>(false);

const { data: suggestions, isLoading, error } = useHentJanzzYrker(input);
Expand Down Expand Up @@ -60,10 +61,9 @@ const Janzz: FunctionComponent<Props> = ({ tittel }) => {
dispatch({ type: SET_JANZZ, kategori });
setInput(capitalizeEmployerName(found.label) || '');
setHasValidSelection(true);
optionSelectedRef.current = true; // Indicate that an option was just selected
optionSelectedRef.current = true;
}
} else {
// Option was deselected
setHasValidSelection(false);
dispatch({ type: SET_JANZZ, kategori: undefined });
}
Expand Down

0 comments on commit a99766d

Please sign in to comment.