Skip to content

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

Add onInteractOutside logic into the SidePanel component directly

Joshen Lim93a72c360c47
diff --git a/packages/ui/src/components/SidePanel/SidePanel.tsx b/packages/ui/src/components/SidePanel/SidePanel.tsx
index 6dc69c307e9..25f4b2214dc 100644
--- a/packages/ui/src/components/SidePanel/SidePanel.tsx
+++ b/packages/ui/src/components/SidePanel/SidePanel.tsx
@@ -109,7 +109,11 @@ const SidePanel = ({
onCloseAutoFocus={props.onCloseAutoFocus}
onEscapeKeyDown={props.onEscapeKeyDown}
onPointerDownOutside={props.onPointerDownOutside}
- onInteractOutside={props.onInteractOutside}
+ onInteractOutside={(event) => {
+ const isToast = (event.target as Element)?.closest('#toast')
+ if (isToast) event.preventDefault()
+ if (props.onInteractOutside) props.onInteractOutside(event)
+ }}
>
{header && <header className={__styles.header}>{header}</header>}
<div className={__styles.contents}>{children}</div>
diff --git a/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx b/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx
index 7e77f5285a0..81bb78295db 100644
--- a/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx
+++ b/studio/components/interfaces/Auth/Policies/PolicyEditorModal/index.tsx
@@ -183,12 +183,6 @@ const PolicyEditorModal: FC<Props> = ({
/>,
]}
onCancel={onSelectCancel}
- onInteractOutside={(event) => {
- const isToast = (event.target as Element)?.closest('#toast')
- if (isToast) {
- event.preventDefault()
- }
- }}
>
<div className="">
{view === POLICY_MODAL_VIEWS.SELECTION ? (
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
index bffc2850680..a82e5d41a4d 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
@@ -198,10 +198,6 @@ const ColumnEditor = ({
applyFunction={(resolve: () => void) => onSaveChanges(resolve)}
/>
}
- onInteractOutside={(event) => {
- const isToast = (event.target as Element)?.closest('#toast')
- if (isToast) event.preventDefault()
- }}
>
<FormSection header={<FormSectionLabel className="lg:!col-span-4">General</FormSectionLabel>}>
<FormSectionContent loading={false} className="lg:!col-span-8">
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
index 5866545dff8..669c8a0a699 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
@@ -143,10 +143,6 @@ const RowEditor = ({
isEditingJson || isSelectingForeignKey ? ' mr-32' : ''
}`}
onCancel={closePanel}
- onInteractOutside={(event) => {
- const isToast = (event.target as Element)?.closest('#toast')
- if (isToast) event.preventDefault()
- }}
>
<form onSubmit={(e) => onSaveChanges(e)} className="h-full">
<div className="flex h-full flex-col">
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx
index 6fbcb1e4a4d..ff985a5ecb0 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SpreadsheetImport/SpreadsheetImport.tsx
@@ -192,10 +192,6 @@ const SpreadsheetImport: FC<Props> = ({
applyFunction={onConfirm}
/>
}
- onInteractOutside={(event) => {
- const isToast = (event.target as Element)?.closest('#toast')
- if (isToast) event.preventDefault()
- }}
>
<SidePanel.Content>
<div className="pt-6">
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 160620babbb..d059fe4cec2 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -183,12 +183,6 @@ const TableEditor: FC<Props> = ({
applyFunction={(resolve: () => void) => onSaveChanges(resolve)}
/>
}
- onInteractOutside={(event) => {
- const isToast = (event.target as Element)?.closest('#toast')
- if (isToast) {
- event.preventDefault()
- }
- }}
>
<>
<SidePanel.Content>