Spaces:
Sleeping
Sleeping
Refactor modal closing logic with CSS fix and JS fallback
Browse files
app.py
CHANGED
|
@@ -714,12 +714,8 @@ with gr.Blocks(title="AnatomyBot - MBBS Anatomy Tutor") as demo:
|
|
| 714 |
# Add custom CSS styling via HTML
|
| 715 |
gr.HTML("""
|
| 716 |
<style>
|
| 717 |
-
/* Modal backdrop using body::after when modal exists */
|
| 718 |
-
body:has(#registration_modal)
|
| 719 |
-
display: block !important;
|
| 720 |
-
}
|
| 721 |
-
|
| 722 |
-
body:has(#registration_modal)::after {
|
| 723 |
content: '';
|
| 724 |
position: fixed;
|
| 725 |
top: 0;
|
|
@@ -1100,7 +1096,17 @@ with gr.Blocks(title="AnatomyBot - MBBS Anatomy Tutor") as demo:
|
|
| 1100 |
modal_submit_btn.click(
|
| 1101 |
fn=handle_modal_submit,
|
| 1102 |
inputs=[modal_name_input, modal_school_input, modal_year_input],
|
| 1103 |
-
outputs=[registration_modal, student_name_display, student_name_state]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1104 |
)
|
| 1105 |
|
| 1106 |
# Event handlers for Learning Mode
|
|
|
|
| 714 |
# Add custom CSS styling via HTML
|
| 715 |
gr.HTML("""
|
| 716 |
<style>
|
| 717 |
+
/* Modal backdrop using body::after when modal exists and is visible */
|
| 718 |
+
body:has(#registration_modal:not([style*="display: none"]))::after {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
content: '';
|
| 720 |
position: fixed;
|
| 721 |
top: 0;
|
|
|
|
| 1096 |
modal_submit_btn.click(
|
| 1097 |
fn=handle_modal_submit,
|
| 1098 |
inputs=[modal_name_input, modal_school_input, modal_year_input],
|
| 1099 |
+
outputs=[registration_modal, student_name_display, student_name_state],
|
| 1100 |
+
js="""
|
| 1101 |
+
(name, school, year) => {
|
| 1102 |
+
if (name && name.trim() !== "" && school && school.trim() !== "" && year) {
|
| 1103 |
+
const modal = document.getElementById('registration_modal');
|
| 1104 |
+
if (modal) {
|
| 1105 |
+
modal.style.display = 'none';
|
| 1106 |
+
}
|
| 1107 |
+
}
|
| 1108 |
+
}
|
| 1109 |
+
"""
|
| 1110 |
)
|
| 1111 |
|
| 1112 |
# Event handlers for Learning Mode
|