changeset 1591:f1d09a4d38dc

browser (jid_search): fix `submit_filter` when there is no parent `<form>`
author Goffi <goffi@goffi.org>
date Sun, 10 Dec 2023 11:01:57 +0100
parents 1d464c72ac12
children 291a7026cb2b
files libervia/web/pages/_browser/jid_search.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/web/pages/_browser/jid_search.py	Sun Dec 10 11:01:19 2023 +0100
+++ b/libervia/web/pages/_browser/jid_search.py	Sun Dec 10 11:01:57 2023 +0100
@@ -47,8 +47,12 @@
         self.search_elt = search_elt
         self.search_elt.bind("input", self.on_search_input)
         if submit_filter:
-            form_elt = self.search_elt.closest("form")
-            form_elt.bind("submit", self.on_form_submit)
+            try:
+                form_elt = self.search_elt.closest("form")
+            except KeyError:
+                log.debug("No parent <form> found, can't apply submit filter.")
+            else:
+                form_elt.bind("submit", self.on_form_submit)
         self.last_query = None
         self.current_query = None
         self.container_elt = container_elt