Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: multi select to always add disabled options back to onChange payload

Joshen Limca6016f97bcd
diff --git a/studio/components/ui/MultiSelect/index.tsx b/studio/components/ui/MultiSelect/index.tsx
index 20e13ec2b4c..a464b9a6698 100644
--- a/studio/components/ui/MultiSelect/index.tsx
+++ b/studio/components/ui/MultiSelect/index.tsx
@@ -39,12 +39,12 @@ export default function MultiSelect({
}: Props) {
const ref = useRef(null)
- const [selected, setSelected] = useState(value || [])
- const [searchString, setSearchString] = useState('')
- const [inputWidth, setInputWidth] = useState(128)
+ const [selected, setSelected] = useState<string[]>(value || [])
+ const [searchString, setSearchString] = useState<string>('')
+ const [inputWidth, setInputWidth] = useState<number>(128)
// Selected is `value` if defined, otherwise use local useState
- const selectedOptions = (value || selected).filter((option) => option !== 'public')
+ const selectedOptions = value || selected
// Calculate width of the Popover
useEffect(() => {
@@ -75,8 +75,14 @@ export default function MultiSelect({
? [...without(_selected, option.value)]
: [..._selected.concat([option.value])]
- setSelected(updatedPayload)
- onChange(updatedPayload)
+ // Payload must always include disabled options
+ const compulsoryOptions = options
+ .filter((option) => option.disabled)
+ .map((option) => option.name)
+ const formattedPayload = [...new Set(updatedPayload.concat(compulsoryOptions))]
+
+ setSelected(formattedPayload)
+ onChange(formattedPayload)
}
const onKeyPress = (e: KeyboardEvent<HTMLInputElement>) => {
diff --git a/studio/pages/project/[ref]/settings/api.tsx b/studio/pages/project/[ref]/settings/api.tsx
index d42025c3bda..17371a1a9aa 100644
--- a/studio/pages/project/[ref]/settings/api.tsx
+++ b/studio/pages/project/[ref]/settings/api.tsx
@@ -500,6 +500,7 @@ const PostgrestConfig = observer(({ config, projectRef }: any) => {
value={updates.db_schema.replace(/ /g, '').split(',')}
// onChange returns array of strings
onChange={(event) => {
+ console.log('onChange', event)
let payload = updates
payload.db_schema = event.join(', ') // permanentSchema.concat(event).join(', ')
setUpdates({ ...payload })