All checks were successful
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.
57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
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,
|
|
)
|
|
}
|