From f3fb0a244d4dcb303a1bcd946b107ece6749c97c Mon Sep 17 00:00:00 2001 From: oskar Date: Fri, 31 Jul 2026 14:56:58 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20linki=20nawigacyjne=20dzia=C5=82aj=C4=85?= =?UTF-8?q?=20z=20podstron=20/privacy=20i=20/platforma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kotwice #offerings/#process/#contact istnieją tylko na stronie głównej, więc z podstron prowadziły w pustkę. Zmienione na ścieżki bezwzględne (/#offerings, /#process, /#contact) w Header.tsx i Footer.tsx. Sama zmiana href nie wystarczyła: sekcje renderuje React, więc przy nawigacji z podstrony przeglądarka rozwiązuje kotwicę zanim element zaistnieje i zostaje na górze strony (zweryfikowane w Chrome — scrollY=0 przy sekcji na 1453px). App.tsx ponawia więc przewinięcie po zamontowaniu sekcji. Kliknięcia w obrębie strony głównej tego nie dotyczą — to nawigacja w tym samym dokumencie, którą przeglądarka obsługuje natywnie i płynnie, bez przeładowania. Co-Authored-By: Claude Opus 5 (1M context) --- src/App.tsx | 18 +++++++++++++++++- src/components/Footer.tsx | 4 ++-- src/components/Header.tsx | 12 +++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e339350..d6bcd68 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import Header from './components/Header'; import Hero from './components/Hero'; import About from './components/About'; @@ -14,6 +14,22 @@ import PlatformPage from './components/PlatformPage'; function App() { const path = window.location.pathname.replace(/\/$/, '') || '/'; + // The landing sections are client-rendered, so when a /#section URL arrives + // with the initial request — following "Oferta"/"Kontakt" from /privacy or + // /platforma — the browser resolves the fragment before the target exists and + // leaves the page at the top. Re-apply the scroll once the sections are + // mounted. In-page clicks never reach this: they are same-document fragment + // navigations that the browser handles natively (smoothly, via .scroll-smooth) + // without remounting App. + useEffect(() => { + if (path !== '/') return; + const id = window.location.hash.slice(1); + if (!id) return; + // Jump rather than smooth-scroll: this only runs on a fresh load, where + // animating the full page height would just be a slow detour. + document.getElementById(id)?.scrollIntoView({ behavior: 'auto' }); + }, [path]); + if (path === '/privacy') { return ; } diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index d3f812f..125aa93 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -27,9 +27,9 @@ const Footer = () => {

Nawigacja

diff --git a/src/components/Header.tsx b/src/components/Header.tsx index eae35cc..3c120c8 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -15,10 +15,12 @@ const Header = () => { }, []); const navLinks = [ - { name: 'Oferta', href: '#offerings' }, + // Root-relative so the links also work from the standalone pages + // (/privacy, /platforma), where these sections do not exist. + { name: 'Oferta', href: '/#offerings' }, { name: 'Platforma', href: '/platforma' }, - { name: 'Proces', href: '#process' }, - { name: 'Kontakt', href: '#contact' }, + { name: 'Proces', href: '/#process' }, + { name: 'Kontakt', href: '/#contact' }, ]; return ( @@ -43,7 +45,7 @@ const Header = () => { {link.name} ))} - + Porozmawiajmy @@ -78,7 +80,7 @@ const Header = () => { ))} setIsMobileMenuOpen(false)} >