@@ -789,6 +789,16 @@ function initGeographyTypingAnimation() {
789789
790790 // Check if geography is selected and update visibility
791791 function checkSelection ( ) {
792+ // Don't show animation if select is disabled (no pathogen selected)
793+ if ( selectElement . disabled ) {
794+ typingElement . style . display = 'none' ;
795+ if ( timeoutId ) {
796+ clearTimeout ( timeoutId ) ;
797+ timeoutId = null ;
798+ }
799+ return ;
800+ }
801+
792802 if ( selectElement . value && selectElement . value !== '' ) {
793803 typingElement . style . display = 'none' ;
794804 if ( timeoutId ) {
@@ -842,12 +852,34 @@ function initGeographyTypingAnimation() {
842852 } , 500 ) ;
843853}
844854
855+ // Update geography select enabled/disabled state based on pathogen selection
856+ function updateGeographySelectState ( ) {
857+ const pathogenSelect = document . getElementById ( 'pathogenSelect' ) ;
858+ const geographySelect = document . getElementById ( 'geographySelect' ) ;
859+
860+ if ( ! pathogenSelect || ! geographySelect ) {
861+ return ;
862+ }
863+
864+ const hasPathogen = pathogenSelect . value && pathogenSelect . value !== '' ;
865+
866+ // Enable or disable geography select based on pathogen selection
867+ geographySelect . disabled = ! hasPathogen ;
868+
869+ // If pathogen is cleared, also clear geography selection
870+ if ( ! hasPathogen && geographySelect . value ) {
871+ geographySelect . value = '' ;
872+ }
873+ }
874+
845875// Initialize dashboard when DOM is loaded
846876let dashboard ;
847877document . addEventListener ( 'DOMContentLoaded' , function ( ) {
848878 dashboard = new AlterDashboard ( ) ;
849879 initPathogenTypingAnimation ( ) ;
850880 initGeographyTypingAnimation ( ) ;
881+ // Initialize geography select state based on pathogen selection
882+ updateGeographySelectState ( ) ;
851883} ) ;
852884
853885// Handle pathogen change - reset geography select and submit form
@@ -862,6 +894,10 @@ function handlePathogenChange() {
862894 if ( geographySelect ) {
863895 geographySelect . value = '' ;
864896 }
897+
898+ // Update geography select state before submitting
899+ updateGeographySelectState ( ) ;
900+
865901 // Show loader before submitting form
866902 const loader = document . getElementById ( 'pageLoader' ) ;
867903 if ( loader ) {
0 commit comments