Skip to content

Commit

Permalink
fix: Add disabled choices support for popup=always dropdowns #1959
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed May 3, 2023
1 parent c4750c9 commit 650611d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/src/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ type DropdownItem = {
text: S
idx: U
checked: B
show: B
show: B,
disabled: B
}

const
Expand Down Expand Up @@ -174,8 +175,8 @@ const
getPageSpecification = () => ({ itemCount: PAGE_SIZE, height: ROW_HEIGHT * PAGE_SIZE } as Fluent.IPageSpecification),
useItems = (choices: Choice[], v?: S | S[]) => {
const
[items, setItems] = React.useState<DropdownItem[]>(choices.map(({ name, label }, idx) =>
({ name, text: label || name, idx, checked: Array.isArray(v) ? v.includes(name) : v === name, show: true }))),
[items, setItems] = React.useState<DropdownItem[]>(choices.map(({ name, label, disabled = false }, idx) =>
({ name, text: label || name, idx, checked: Array.isArray(v) ? v.includes(name) : v === name, show: true, disabled }))),
onSearchChange = (_e?: React.ChangeEvent<HTMLInputElement>, newVal = '') => setItems(items => items.map(i => ({ ...i, show: fuzzysearch(i.text, newVal) })))

return [items, setItems, onSearchChange] as const
Expand All @@ -190,6 +191,7 @@ const
}}
onChange={onChecked(item.name)}
className={item.checked ? css.dialogCheckedRow : ''}
disabled={item.disabled}
checked={item.checked} />
: null,

Expand Down

0 comments on commit 650611d

Please sign in to comment.