Drop down with a very long option
A drop down where one option is really long and should wrap.
import { useRef, useState } from 'react';
import { DropDown } from '@citizensadvice/react-combo-boxes';
const options = [
'Apple',
'Banana',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
];
export function Example() {
const [value, setValue] = useState(null);
const ref = useRef();
return (
<>
<div
className="label"
onClick={() => ref.current.focus()}
id="drop-down-label"
>
Drop down
</div>
<DropDown
ref={ref}
id="drop-down"
aria-labelledby="drop-down-label"
value={value}
onValue={setValue}
options={options}
/>
<label htmlFor="output">Current value</label>
<output
htmlFor="drop-down"
id="output"
>
{JSON.stringify(value, undefined, ' ')}
</output>
</>
);
}