Skip to content

Commit

Permalink
fix(Select): fire onClick for initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
KayBeSee committed Oct 11, 2022
1 parent 33140f0 commit 0a0e987
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/frontend/src/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useState } from 'react';
import React, { Fragment, useEffect, useState } from 'react';
import styled from 'styled-components';
import { Listbox, Transition } from '@headlessui/react';
import { CheckIcon, SelectorIcon } from '@heroicons/react/solid';
Expand All @@ -21,6 +21,11 @@ export const Select = React.memo(
({ label, options, initialSelection, error, id }: Props) => {
const [selected, setSelected] = useState(initialSelection || options[0]);

useEffect(() => {
const initial = initialSelection || options[0];
initial.onClick();
}, []);

return (
<Listbox
value={selected}
Expand Down

0 comments on commit 0a0e987

Please sign in to comment.