mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem Studio lets people create an item while selecting one, but the design system does not document this pattern. ## Solution Document the create action in the Combobox guide with a focused example. The action sits below the options and leaves the current selection unchanged. Products can connect it to their own creation flow. | After | | --- | | <img width="552" height="352" alt="CleanShot 2026-09-30 at 10 57 46@2x" src="https://github.com/user-attachments/assets/69c8069c-d4f9-45e2-b3a1-6e5431e2aff9" /> | ## Review instructions 1. Open the design system Combobox page and find “[Create from list](https://design-system-git-dnywh-document-select-create-action-supabase.vercel.app/design-system/docs/components/combobox#create-from-list)”. 2. Select a bucket, then choose “New bucket”. Because it’s just an example, the selector closes without replacing the selected bucket. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a combobox example with a separate “New bucket” action. Choosing it closes the menu without changing the current selection; choosing an existing bucket updates the selection. * Added documentation showing how to use this create-action pattern, including guidance on labeling and positioning the action. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
'use client'
|
|
|
|
import { Check, Plus } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import {
|
|
ComboboxTrigger,
|
|
Command,
|
|
CommandGroup,
|
|
CommandItem,
|
|
CommandList,
|
|
CommandSeparator,
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from 'ui'
|
|
|
|
const buckets = ['Images', 'Exports']
|
|
|
|
export default function ComboboxCreateOption() {
|
|
const [selectedBucket, setSelectedBucket] = useState('')
|
|
const [isListOpen, setIsListOpen] = useState(false)
|
|
|
|
return (
|
|
<Popover open={isListOpen} onOpenChange={setIsListOpen}>
|
|
<PopoverTrigger asChild>
|
|
<ComboboxTrigger
|
|
aria-expanded={isListOpen}
|
|
data-state={isListOpen ? 'open' : 'closed'}
|
|
className="w-[240px]"
|
|
>
|
|
{selectedBucket || 'Select a bucket'}
|
|
</ComboboxTrigger>
|
|
</PopoverTrigger>
|
|
<PopoverContent className="w-[240px] p-0" align="start">
|
|
<Command>
|
|
<CommandList>
|
|
<CommandGroup>
|
|
{buckets.map((bucket) => (
|
|
<CommandItem
|
|
key={bucket}
|
|
value={bucket}
|
|
className="cursor-pointer justify-between"
|
|
onSelect={() => {
|
|
setSelectedBucket(bucket)
|
|
setIsListOpen(false)
|
|
}}
|
|
>
|
|
{bucket}
|
|
{selectedBucket === bucket && <Check size={14} />}
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
<CommandSeparator />
|
|
<CommandGroup>
|
|
<CommandItem
|
|
className="cursor-pointer"
|
|
onSelect={() => {
|
|
setIsListOpen(false)
|
|
// Open the creation flow here without changing the selected bucket.
|
|
}}
|
|
>
|
|
<Plus size={14} className="mr-2" />
|
|
New bucket
|
|
</CommandItem>
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</Command>
|
|
</PopoverContent>
|
|
</Popover>
|
|
)
|
|
}
|