Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/spec-driven-workflow.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You review at the boundaries between phases, not after every line of code.

== Workflow Overview

image::workflow-diagram.png[Workflow Overview,width=800]
image::docs/workflow-diagram.png[Workflow Overview,width=800]

== Cross-Cutting Concerns

Expand Down
2 changes: 1 addition & 1 deletion docs/spec-driven-workflow.de.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Man reviewt an den Übergängen zwischen Phasen, nicht nach jeder einzelnen Code

== Workflow-Übersicht

image::workflow-diagram.png[Workflow-Übersicht,width=800]
image::docs/workflow-diagram.png[Workflow-Übersicht,width=800]

== Querschnittsthemen

Expand Down
5 changes: 4 additions & 1 deletion website/src/components/anchor-modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { i18n } from '../i18n.js'
import { fetchAnchorsData } from '../utils/data-loader.js'
import { getRouteBeforeModal } from '../utils/router.js'
import { getRouteBeforeModal, getScrollBeforeModal } from '../utils/router.js'

let asciidoctor = null

Expand Down Expand Up @@ -104,7 +104,10 @@ export function closeModal() {
// Return to the page that was active before the modal opened
if (window.location.hash.startsWith('#/anchor/')) {
const returnTo = getRouteBeforeModal() || '/'
const scrollY = getScrollBeforeModal()
window.location.hash = '#' + returnTo
// Restore scroll position after the hashchange event
requestAnimationFrame(() => window.scrollTo(0, scrollY))
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion website/src/utils/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const routes = new Map()
let currentRoute = null
let routeBeforeModal = null
let scrollBeforeModal = 0

/**
* Register a route handler
Expand Down Expand Up @@ -55,8 +56,9 @@ function handleRoute() {
const safeAnchorId = /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(anchorId) ? anchorId : null
if (!safeAnchorId) return

// Remember the current route so we can return to it when the modal closes
// Remember the current route and scroll position for restoring after modal close
routeBeforeModal = currentRoute
scrollBeforeModal = window.scrollY

// Only navigate to home if no page is currently rendered
if (!currentRoute) {
Expand All @@ -66,6 +68,9 @@ function handleRoute() {
homeHandler()
}
}
// Restore scroll position (browser resets it on hash change)
window.scrollTo(0, scrollBeforeModal)

// Open the anchor modal as overlay on current page
// Import dynamically to avoid circular dependency
import('../components/anchor-modal.js').then(({ showAnchorDetails }) => {
Expand Down Expand Up @@ -105,3 +110,11 @@ export function isActive(path) {
export function getRouteBeforeModal() {
return routeBeforeModal
}

/**
* Get the scroll position that was active before the anchor modal opened
* @returns {number} Scroll Y position
*/
export function getScrollBeforeModal() {
return scrollBeforeModal
}
Loading