From 650611d9e6c70bb805929e531d9ae35d67be7d9f Mon Sep 17 00:00:00 2001 From: Marek Mihok Date: Wed, 3 May 2023 11:11:20 +0200 Subject: [PATCH] fix: Add disabled choices support for popup=always dropdowns #1959 --- ui/src/dropdown.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/src/dropdown.tsx b/ui/src/dropdown.tsx index 3b23cffbda5..02687be4ba8 100644 --- a/ui/src/dropdown.tsx +++ b/ui/src/dropdown.tsx @@ -68,7 +68,8 @@ type DropdownItem = { text: S idx: U checked: B - show: B + show: B, + disabled: B } const @@ -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(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(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, newVal = '') => setItems(items => items.map(i => ({ ...i, show: fuzzysearch(i.text, newVal) }))) return [items, setItems, onSearchChange] as const @@ -190,6 +191,7 @@ const }} onChange={onChecked(item.name)} className={item.checked ? css.dialogCheckedRow : ''} + disabled={item.disabled} checked={item.checked} /> : null,