Skip to content

Commit

Permalink
fix: ListBox now has optionsWidth prop to override width
Browse files Browse the repository at this point in the history
  • Loading branch information
MildTomato committed Feb 14, 2022
1 parent 9fb628a commit 9ed18c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Listbox/Listbox2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface Props
defaultValue?: any
borderless?: boolean
validation?: (x: any) => void
optionsWidth?: number
}

function Listbox({
Expand All @@ -60,6 +61,7 @@ function Listbox({
borderless = false,
validation,
disabled,
optionsWidth,
}: Props) {
const [selected, setSelected] = useState(undefined)
const [selectedNode, setSelectedNode] = useState<any>({})
Expand Down Expand Up @@ -100,9 +102,10 @@ function Listbox({

function handleResize() {
// Set window width/height to state

document.documentElement.style.setProperty(
'--width-listbox',
`${triggerRef.current?.offsetWidth}px`
`${optionsWidth ? optionsWidth : triggerRef.current?.offsetWidth}px`
)
}

Expand Down

0 comments on commit 9ed18c0

Please sign in to comment.