Browse Source

Fix bug when opening/closing `ui.select` on air (#3561)

* handle non-string arguments correctly

* drop unnecessary event arguments

* cleanup

---------

Co-authored-by: Rodja Trappe <rodja@zauberzeug.com>
Falko Schindler 9 months ago
parent
commit
06afeae389
1 changed files with 5 additions and 4 deletions
  1. 5 4
      nicegui/air.py

+ 5 - 4
nicegui/air.py

@@ -146,10 +146,11 @@ class Air:
             if client_id not in Client.instances:
                 return
             client = Client.instances[client_id]
-            if data['msg']['args'] and data['msg']['args'][0].startswith('{"socket_id":'):
-                args = json.loads(data['msg']['args'][0])
-                args['socket_id'] = client_id  # HACK: translate socket_id of ui.scene's init event
-                data['msg']['args'][0] = json.dumps(args)
+            args = data['msg']['args']
+            if args and isinstance(args[0], str) and args[0].startswith('{"socket_id":'):
+                arg0 = json.loads(args[0])
+                arg0['socket_id'] = client_id  # HACK: translate socket_id of ui.scene's init event
+                args[0] = json.dumps(arg0)
             client.handle_event(data['msg'])
 
         @self.relay.on('javascript_response')