The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: scroll to required fields on support form submit (#49147)
Monica Khouryfff592805662
diff --git a/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx b/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsxindex b1806a24497..843bbedc875 100644--- a/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx+++ b/apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx@@ -91,7 +91,11 @@ function CategorySelector({ form }: CategorySelectorProps) {<FormItemLayout hideMessage layout="vertical" label="What issue are you having?"><FormControl><Select {...fieldWithoutRef} defaultValue={field.value} onValueChange={onValueChange}>- <SelectTrigger aria-label="Select an issue" className="w-full">+ <SelectTrigger+ data-support-field="category"+ aria-label="Select an issue"+ className="w-full"+ ><SelectValue placeholder="Select an issue">{field.value? CATEGORY_OPTIONS.find((o) => o.value === field.value)?.labeldiff --git a/apps/studio/components/interfaces/Support/ClientLibraryInfo.tsx b/apps/studio/components/interfaces/Support/ClientLibraryInfo.tsxindex 43a644c0fc0..e60259a8f7f 100644--- a/apps/studio/components/interfaces/Support/ClientLibraryInfo.tsx+++ b/apps/studio/components/interfaces/Support/ClientLibraryInfo.tsx@@ -43,7 +43,11 @@ export function ClientLibraryInfo({ form, category, library }: ClientLibraryInfo<FormItemLayout layout="vertical" label="Which library are you having issues with"><FormControl><Select {...field} defaultValue={field.value} onValueChange={field.onChange}>- <SelectTrigger className="w-full" aria-label="Select a library">+ <SelectTrigger+ data-support-field="library"+ className="w-full"+ aria-label="Select a library"+ ><SelectValue placeholder="Select a library" /></SelectTrigger><SelectContent>diff --git a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx b/apps/studio/components/interfaces/Support/SupportForm.utils.tsxindex b072b3f5fc1..6a7ecbb705d 100644--- a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx+++ b/apps/studio/components/interfaces/Support/SupportForm.utils.tsx@@ -224,3 +224,34 @@ export async function selectInitialOrgAndProject({orgSlug: orgs[0]?.slug ?? null,}}++// Chrome blocks scrollIntoView (triggered by .focus()) when overflow-x: hidden and+// overflow-y: auto are on the same element. Manually scroll the sidebar instead.+export function scrollToRequiredField(formId: string, fieldName: string) {+ const form = document.getElementById(formId)+ if (!form) return++ // Selects use data-support-field since they have no name attr; inputs/textareas use name.+ const el =+ form.querySelector(`[data-support-field="${fieldName}"]`) ??+ form.querySelector(`[name="${fieldName}"]`)+ if (!(el instanceof HTMLElement)) return++ const scrollContainer = findScrollableParent(el)+ if (scrollContainer) {+ const offset = el.getBoundingClientRect().top - scrollContainer.getBoundingClientRect().top - 80+ scrollContainer.scrollTo({ top: scrollContainer.scrollTop + offset, behavior: 'smooth' })+ }++ el.focus({ preventScroll: true })+}++function findScrollableParent(el: HTMLElement): HTMLElement | null {+ let parent = el.parentElement+ while (parent && parent !== document.body) {+ const { overflowY } = window.getComputedStyle(parent)+ if (overflowY === 'auto' || overflowY === 'scroll') return parent+ parent = parent.parentElement+ }+ return null+}diff --git a/apps/studio/components/interfaces/Support/SupportFormV3.tsx b/apps/studio/components/interfaces/Support/SupportFormV3.tsxindex 764dc5959eb..d3d86d97e68 100644--- a/apps/studio/components/interfaces/Support/SupportFormV3.tsx+++ b/apps/studio/components/interfaces/Support/SupportFormV3.tsx@@ -36,6 +36,7 @@ import {getOrgSubscriptionPlan,NO_ORG_MARKER,NO_PROJECT_MARKER,+ scrollToRequiredField,} from './SupportForm.utils'import { SupportFormDirectEmailContent } from './SupportFormDirectEmailInfo'import { getProjectAuthConfig } from '@/data/auth/auth-config-query'@@ -148,6 +149,8 @@ export const SupportFormV3 = ({type: 'manual',message: "Please select the library that you're facing issues with",})+ // setError triggers a re-render; wait for it before querying aria-invalid+ requestAnimationFrame(() => scrollToRequiredField('support-form', 'library'))return}@@ -223,7 +226,9 @@ export const SupportFormV3 = ({submitSupportTicket(payload)}- const handleFormSubmit = form.handleSubmit(onSubmit)+ const handleFormSubmit = form.handleSubmit(onSubmit, (errors) => {+ scrollToRequiredField('support-form', Object.keys(errors)[0])+ })const handleSubmitButtonClick: MouseEventHandler<HTMLButtonElement> = (event) => {handleFormSubmit(event)