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
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:
1 parent
c9175bd2fd
commit
295c7e7efc
6 files changed
+173
-6
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { useEffect } from 'react'
|
||||
|
||||
let lockDepth = 0
|
||||
const saved = {
|
||||
appMainScrollTop: 0,
|
||||
bodyScrollTop: 0,
|
||||
appMainOverflow: '',
|
||||
appMainTouchAction: '',
|
||||
}
|
||||
|
||||
function queryAppMain() {
|
||||
return document.querySelector('.app-main')
|
||||
}
|
||||
|
||||
function applyLock() {
|
||||
document.documentElement.classList.add('modal-scroll-locked')
|
||||
|
||||
const appMain = queryAppMain()
|
||||
if (appMain) {
|
||||
saved.appMainScrollTop = appMain.scrollTop
|
||||
saved.appMainOverflow = appMain.style.overflow
|
||||
saved.appMainTouchAction = appMain.style.touchAction
|
||||
appMain.style.overflow = 'hidden'
|
||||
appMain.style.touchAction = 'none'
|
||||
}
|
||||
|
||||
saved.bodyScrollTop = window.scrollY || document.documentElement.scrollTop || 0
|
||||
document.body.style.overflow = 'hidden'
|
||||
document.body.style.overscrollBehavior = 'none'
|
||||
}
|
||||
|
||||
function releaseLock() {
|
||||
document.documentElement.classList.remove('modal-scroll-locked')
|
||||
|
||||
const appMain = queryAppMain()
|
||||
if (appMain) {
|
||||
appMain.style.overflow = saved.appMainOverflow
|
||||
appMain.style.touchAction = saved.appMainTouchAction
|
||||
appMain.scrollTop = saved.appMainScrollTop
|
||||
}
|
||||
|
||||
document.body.style.overflow = ''
|
||||
document.body.style.overscrollBehavior = ''
|
||||
if (saved.bodyScrollTop) {
|
||||
window.scrollTo(0, saved.bodyScrollTop)
|
||||
}
|
||||
}
|
||||
|
||||
/** Hintergrund-Scroll sperren (.app-main + body), verschachtelte Modals via Zähler. */
|
||||
export function useModalScrollLock(active) {
|
||||
useEffect(() => {
|
||||
if (!active) return undefined
|
||||
lockDepth += 1
|
||||
if (lockDepth === 1) applyLock()
|
||||
return () => {
|
||||
lockDepth = Math.max(0, lockDepth - 1)
|
||||
if (lockDepth === 0) releaseLock()
|
||||
}
|
||||
}, [active])
|
||||
}
|
||||
Reference in new issue
Block a user