Falko Schindler 1 سال پیش
والد
کامیت
e3f9fb333a
2فایلهای تغییر یافته به همراه5 افزوده شده و 4 حذف شده
  1. 1 1
      nicegui/elements/mixins/visibility.py
  2. 4 3
      tests/test_events.py

+ 1 - 1
nicegui/elements/mixins/visibility.py

@@ -19,7 +19,7 @@ class Visibility:
     @property
     def is_ignoring_events(self) -> bool:
         """Return whether the element is currently ignoring events."""
-        return
+        return not self.visible and self.ignores_events_when_hidden
 
     def bind_visibility_to(self,
                            target_object: Any,

+ 4 - 3
tests/test_events.py

@@ -2,6 +2,7 @@ import asyncio
 
 import pytest
 from selenium.webdriver.common.by import By
+from typing_extensions import Literal
 
 from nicegui import ui
 from nicegui.events import ClickEventArguments
@@ -161,10 +162,10 @@ def test_throttling_variants(screen: Screen):
     assert events == [3]
 
 
-@pytest.mark.parametrize('attribue', ['disabled', 'hidden'])
-def test_server_side_validation(screen: Screen, attribue: str):
+@pytest.mark.parametrize('attribute', ['disabled', 'hidden'])
+def test_server_side_validation(screen: Screen, attribute: Literal['disabled', 'hidden']):
     b = ui.button('Button', on_click=lambda: ui.label('Success'))
-    b.disable() if attribue == 'disabled' else b.set_visibility(False)
+    b.disable() if attribute == 'disabled' else b.set_visibility(False)
     ui.button('Hack', on_click=lambda: ui.run_javascript(f'''
         getElement({b.id}).$emit("click", {{"id": {b.id}, "listener_id": "{list(b._event_listeners.keys())[0]}"}});
     ''', respond=False))