Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed Apr 19, 2024
1 parent 3ff1b45 commit 9b2bf15
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/frontend/components/checks/SmartSelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ export default function SmartCheckSelect({
: onChange(null)
}

function getRenderedValues() {
if (fixedValue?.length >= 4) {
return <Pill>{fixedValue?.length} selected</Pill>
}
return fixedValue.map((item) => (
<Pill
key={item}
withRemoveButton
maw={130}
onRemove={() => handleValueRemove(item)}
>
{renderLabel(data?.find((d) => getItemValue(d) === item))}
</Pill>
))
}
const renderedValue = multiple
? fixedValue.map((item) => (
<Pill
key={item}
withRemoveButton
maw={130}
onRemove={() => handleValueRemove(item)}
>
{renderLabel(data?.find((d) => getItemValue(d) === item))}
</Pill>
))
? getRenderedValues()
: renderLabel(data?.find((d) => getItemValue(d) === value))

function optionsFilter(item) {
Expand Down Expand Up @@ -123,10 +129,7 @@ export default function SmartCheckSelect({
w="min-content"
>
<Combobox.Target>
<Pill.Group
style={{ flexWrap: "nowrap", overflow: "hidden" }}
maw="300"
>
<Pill.Group style={{ flexWrap: "nowrap", overflow: "hidden" }}>
{renderedValue}
</Pill.Group>
</Combobox.Target>
Expand Down

0 comments on commit 9b2bf15

Please sign in to comment.