Skip to content

Commit

Permalink
Fix controlled example
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasBoll committed Oct 14, 2024
1 parent 1ae1f54 commit 932fa7a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const items = [
];

export const Controlled = () => {
const formRef = React.useRef<HTMLFormElement>(null);
const [value, setValue] = React.useState('1');
const [label, setLabel] = React.useState('Cheese');

Expand All @@ -36,6 +37,7 @@ export const Controlled = () => {
console.log('form submitted');
e.preventDefault();
}}
ref={formRef}
>
<Flex gap="s" flexDirection="column">
<MultiSelect items={items}>
Expand Down Expand Up @@ -71,7 +73,7 @@ export const Controlled = () => {
</SecondaryButton>
<SecondaryButton
onClick={e => {
const input = document.querySelector('[name=toppings]') as HTMLInputElement;
const input = formRef.current.querySelector('[name=toppings]') as HTMLInputElement;
input.value = '1, 2';
}}
>
Expand Down

0 comments on commit 932fa7a

Please sign in to comment.