1717 position : relative;
1818 }
1919
20+ /* Prevent body scroll when modal is open */
21+ body .modal-open {
22+ overflow : hidden;
23+ width : 100% ;
24+ }
25+
2026 body ::before {
2127 content : '' ;
2228 position : fixed;
@@ -513,6 +519,7 @@ <h2 class="modal-title" id="modalTitle"></h2>
513519 let currentChart = null ;
514520 let allSubmissions = [ ] ;
515521 let currentUsername = '' ;
522+ let savedScrollPosition = 0 ;
516523
517524 // Difficulty ranges for categorization
518525 const difficultyRanges = [
@@ -526,6 +533,31 @@ <h2 class="modal-title" id="modalTitle"></h2>
526533 { min : 2300 , max : 3500 , label : "2300+" , color : "#AA0000" }
527534 ] ;
528535
536+ // Modal scroll management functions
537+ function openModal ( ) {
538+ // Save current scroll position
539+ savedScrollPosition = window . pageYOffset ;
540+
541+ // Prevent body scroll
542+ document . body . classList . add ( 'modal-open' ) ;
543+ document . body . style . top = `-${ savedScrollPosition } px` ;
544+
545+ // Show modal
546+ document . getElementById ( 'problemModal' ) . style . display = 'block' ;
547+ }
548+
549+ function closeModal ( ) {
550+ const modal = document . getElementById ( 'problemModal' ) ;
551+ modal . style . display = 'none' ;
552+
553+ // Restore body scroll
554+ document . body . classList . remove ( 'modal-open' ) ;
555+ document . body . style . top = '' ;
556+
557+ // Restore scroll position
558+ window . scrollTo ( 0 , savedScrollPosition ) ;
559+ }
560+
529561 // Initialize the application
530562 function initializeApp ( ) {
531563 // Set default dates (last year)
@@ -643,7 +675,6 @@ <h2 class="modal-title" id="modalTitle"></h2>
643675 }
644676
645677 function showProblemDetails ( difficultyRange ) {
646- const modal = document . getElementById ( 'problemModal' ) ;
647678 const modalTitle = document . getElementById ( 'modalTitle' ) ;
648679 const modalBody = document . getElementById ( 'modalBody' ) ;
649680
@@ -728,11 +759,7 @@ <h2 class="modal-title" id="modalTitle"></h2>
728759 } ) ;
729760
730761 modalBody . innerHTML = html ;
731- modal . style . display = 'block' ;
732- }
733-
734- function closeModal ( ) {
735- document . getElementById ( 'problemModal' ) . style . display = 'none' ;
762+ openModal ( ) ;
736763 }
737764
738765 async function analyzePerformance ( ) {
0 commit comments