deephaven / deephaven-plugins

Deephaven Plugins
11 stars 15 forks source link

Event props do not work on `ui.text_field`, circular structure error logged to browser console #893

Closed mofojed closed 1 month ago

mofojed commented 2 months ago

Description

The props for events on ui.text_field are not wired up correctly and do not work, logging an error in the browser console.

Steps to reproduce

  1. Create a ui.textfield with on_focus and on_blur events: tf = ui.text_field(label="Focus me", on_focus=lambda: print("Focus!"), on_blur=lambda: print("Blur!"))
  2. Click in and out of the text field that's shown

Expected results

  1. "Focus!" and "Blur!" should be printed in the python console

Actual results

  1. Nothing is printed to the Python console. An error is logged in the browser logs:
    Uncaught (in promise) Error: Converting circular structure to JSON
    --> starting at object with constructor 'HTMLInputElement'
    |     property '__reactFiber$a5vcbx0bdh' -> object with constructor 'nXe'
    --- property 'stateNode' closes the circle
    at new JSONRPCErrorException2 (eval at <anonymous> (vendor-808b021e.js:1:1), <anonymous>:6719:28)
    at JSONRPCClient2.eval (eval at <anonymous> (vendor-808b021e.js:1:1), <anonymous>:6961:43)
    at step (eval at <anonymous> (vendor-808b021e.js:1:1), <anonymous>:6868:19)
    at Object.eval [as next] (eval at <anonymous> (vendor-808b021e.js:1:1), <anonymous>:6815:14)
    at fulfilled (eval at <anonymous> (vendor-808b021e.js:1:1), <anonymous>:6786:24)

Versions

Engine Version: 0.36.1 Web UI Version: 0.90.0 Java Version: 11.0.24 Barrage Version: 0.6.0 Browser Name: Chrome 128 OS Name: Linux @deephaven/js-plugin-ui: 0.21.0

mofojed commented 2 months ago

Need to correctly deserialize the events like we already do for Button/Toggle button. We won't be able to just use useButtonProps though, but perhaps you can break useButtonProps down into a couple of hooks.