Refactor modal components to use FormModalOverlay for improved consistency and functionality
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 38s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m9s

- Replaced div elements with FormModalOverlay in SaveExercisesAsModuleModal, TrainingPlanningUnitFormModal, and TrainingPublishToFrameworkModal for a unified modal structure.
- Enhanced modal styling and behavior, including adjustments for responsiveness and accessibility.
- Introduced new CSS rules to manage overflow and scrolling behavior when modals are active, improving user experience across devices.
This commit is contained in:
Lars committed 2026-05-19 10:47:44 +02:00
1 parent c9175bd2fd
commit 295c7e7efc
6 files changed
+173 -6

No files matched your search

@@ -0,0 +1,56 @@
import React, { useEffect, useRef } from 'react'
import { createPortal } from 'react-dom'
import { useModalScrollLock } from '../hooks/useModalScrollLock'
/**
* Formular-Modal am document.body (Portal) — volle Viewport-Breite, kein Hintergrund-Scroll.
*/
export default function FormModalOverlay({
open,
children,
raised = false,
className = '',
onBackdropClick,
'data-testid': testId,
}) {
const overlayRef = useRef(null)
useModalScrollLock(open)
useEffect(() => {
if (!open) return undefined
const t = window.setTimeout(() => {
overlayRef.current?.focus({ preventScroll: true })
}, 0)
return () => clearTimeout(t)
}, [open])
if (!open) return null
const overlayClass = [
'modal-overlay',
'modal-overlay--form',
raised ? 'modal-overlay--raised' : '',
className,
]
.filter(Boolean)
.join(' ')
return createPortal(
<div
ref={overlayRef}
tabIndex={-1}
data-testid={testId}
className={overlayClass}
onClick={
onBackdropClick
? (e) => {
if (e.target === e.currentTarget) onBackdropClick()
}
: undefined
}
>
{children}
</div>,
document.body,
)
}