Skip to content

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

Use asPath as dependencies to trigger jump to tag anchors

Long Hoang3f1a92f7509a
diff --git a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
index bec0db6789c..77cf1580561 100644
--- a/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/ComputeSizeSelection.tsx
@@ -1,5 +1,6 @@
-import { FC, useEffect } from 'react'
import Link from 'next/link'
+import { FC, useEffect } from 'react'
+import { useRouter } from 'next/router'
import { Badge, Button, IconExternalLink, Radio } from 'ui'
import { useFlag } from 'hooks'
@@ -22,22 +23,26 @@ const ComputeSizeSelection: FC<Props> = ({
onSelectOption,
}) => {
const { ref } = useParams()
- const addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
-
+ const { asPath } = useRouter()
useEffect(() => {
- const hash = window.location.hash
- if (hash.length > 0) {
+ const hash = asPath.split('#')[1]
+ console.log('hash', hash)
+ if (hash !== undefined) {
window.location.hash = ''
window.location.hash = hash
}
- })
-
+ }, [asPath])
+ const addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
return (
- <div className="space-y-4" id="compute-addon">
+ <div className="space-y-4">
<div className="flex items-center justify-between">
<div>
<div className="flex items-center space-x-2">
- <h4 className="text-lg">Compute add-ons</h4>
+ <h4 id="compute-addon" className="text-lg">
+ <Link href="#compute-addon" prefetch={false}>
+ <a>Compute add-ons</a>
+ </Link>
+ </h4>
<Badge color="green">Optional</Badge>
</div>
<p className="text-sm text-scale-1100">
diff --git a/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
index 7a69cf1077a..31b290805f4 100644
--- a/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/CustomDomainSelection.tsx
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { FC, useEffect } from 'react'
+import { useRouter } from 'next/router'
import { Badge, Button, Radio } from 'ui'
import { useFlag } from 'hooks'
@@ -23,20 +24,23 @@ const CustomDomainSelection: FC<Props> = ({
}) => {
const { ref } = useParams()
const addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
-
+ const { asPath } = useRouter()
useEffect(() => {
- const hash = window.location.hash
- if (hash.length > 0) {
+ const hash = asPath.split('#')[1]
+ if (hash !== undefined) {
window.location.hash = ''
window.location.hash = hash
}
- })
-
+ }, [asPath])
return (
- <div className="space-y-4" id="custom-domain-addon">
+ <div className="space-y-4">
<div>
<div className="flex items-center space-x-2">
- <h4 className="text-lg">Custom Domains</h4>
+ <h4 id="custom-domain-addon" className="text-lg">
+ <Link href="#custom-domain-addon" prefetch={false}>
+ <a>Custom Domains</a>
+ </Link>
+ </h4>
<Badge color="green">Optional</Badge>
</div>
<p className="text-sm text-scale-1100">Present a branded experience to your users</p>
diff --git a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
index ea74a0a78c5..6224ff6cf64 100644
--- a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { FC, useEffect } from 'react'
+import { useRouter } from 'next/router'
import { Badge, IconAlertCircle, Radio, Button } from 'ui'
import { useFlag, useStore } from 'hooks'
@@ -29,23 +30,26 @@ const PITRDurationSelection: FC<Props> = ({
const projectRegion = ui.selectedProject?.region ?? ''
+ // Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
+ const sufficientPgVersion = getSemanticVersion(ui.selectedProject?.dbVersion ?? '') >= 141044
+ const isDisabledForRegion = ['ap-northeast-2'].includes(projectRegion)
+ const { asPath } = useRouter()
useEffect(() => {
- const hash = window.location.hash
- if (hash.length > 0) {
+ const hash = asPath.split('#')[1]
+ if (hash !== undefined) {
window.location.hash = ''
window.location.hash = hash
}
- })
-
- // Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
- const sufficientPgVersion = getSemanticVersion(ui.selectedProject?.dbVersion ?? '') >= 141044
- const isDisabledForRegion = ['ap-northeast-2'].includes(projectRegion)
-
+ }, [asPath])
return (
- <div className="space-y-4" id="pitr-addon">
+ <div className="space-y-4">
<div>
<div className="flex items-center space-x-2">
- <h4 className="text-lg">Point in time recovery (PITR)</h4>
+ <h4 id="pitr-addon" className="text-lg">
+ <Link href="#pitr-addon" prefetch={false}>
+ <a>Point in time recovery (PITR)</a>
+ </Link>
+ </h4>
<Badge color="green">Optional</Badge>
</div>
<p className="text-sm text-scale-1100">
diff --git a/studio/components/interfaces/Billing/AddOns/SupportPlan.tsx b/studio/components/interfaces/Billing/AddOns/SupportPlan.tsx
index 979319219d1..3208912bace 100644
--- a/studio/components/interfaces/Billing/AddOns/SupportPlan.tsx
+++ b/studio/components/interfaces/Billing/AddOns/SupportPlan.tsx
@@ -1,5 +1,6 @@
-import { FC, useEffect } from 'react'
import Link from 'next/link'
+import { FC, useEffect } from 'react'
+import { useRouter } from 'next/router'
import { Button } from 'ui'
import { useParams } from 'common/hooks'
@@ -9,20 +10,23 @@ interface Props {
const SupportPlan: FC<Props> = ({ currentOption }) => {
const { ref } = useParams()
-
+ const { asPath } = useRouter()
useEffect(() => {
- const hash = window.location.hash
- if (hash.length > 0) {
+ const hash = asPath.split('#')[1]
+ if (hash !== undefined) {
window.location.hash = ''
window.location.hash = hash
}
- })
-
+ }, [asPath])
return (
- <div className="space-y-4" id="support-addon">
+ <div className="space-y-4">
<div>
<div className="flex items-center space-x-2">
- <h4 className="text-lg">Support Plan</h4>
+ <h4 id="support-addon" className="text-lg">
+ <Link href="#support-addon" prefetch={false}>
+ <a>Support Plan</a>
+ </Link>
+ </h4>
</div>
<p className="text-sm text-scale-1100">Designated support with guaranteed response times</p>
</div>