Skip to content

Commit e3f2587

Browse files
Fix scroll to URL fragment (#hash) 🔗
1 parent ab321f9 commit e3f2587

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/App.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useState, useEffect } from 'react';
22

33
import Intro from './components/Intro.jsx';
44
import Navbar from './components/Navbar.jsx';
@@ -17,6 +17,20 @@ const SHOW_CONTACT_SECTION = true;
1717
export default function App() {
1818
const [introComplete, setIntroComplete] = useState(false);
1919

20+
useEffect(() => {
21+
if (!introComplete) return;
22+
const hash = window.location.hash;
23+
if (!hash) return;
24+
25+
const timer = setTimeout(() => {
26+
const el = document.querySelector(hash);
27+
if (el) {
28+
el.scrollIntoView({ behavior: 'smooth' });
29+
}
30+
}, 300);
31+
return () => clearTimeout(timer);
32+
}, [introComplete]);
33+
2034
return (
2135
<>
2236
<div id="global-site-bg"></div>

src/constants/eventDates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const REGISTRATION_OPEN = new Date('March 17, 2026 00:00:00');
22
export const REGISTRATION_CLOSE = new Date('March 24, 2026 06:00:00');
33
export const TEMPLATE_RELEASE = new Date('March 25, 2026 00:00:00');
44
export const PROPOSAL_OPEN = new Date('March 30, 2026 00:00:00');
5-
export const PROPOSAL_CLOSE = new Date('April 24, 2026 23:59:59');
5+
export const PROPOSAL_CLOSE = new Date('April 23, 2026 23:59:59');
66

77
export const PORTAL_URL = 'https://isportal.hackx.lk/';
88
export const TEMPLATE_URL = '/assets/ideasprint-proposal-template.docx';

0 commit comments

Comments
 (0)