Add on_keyup and value_input for code editor
Closes https://github.com/holoviz/panel/issues/5486
Although this is a breaking change, I think it's worth it because if you try to bind a callback that runs the code from value, it triggers on every keystroke... and as you might imagine, writing valid code often requires more than one character change.
import panel as pn
pn.extension()
def callback(value):
exec(value)
code = pn.widgets.CodeEditor(value="import this")
pn.bind(callback, code.param.value, watch=True)
code.show()
Previously, removing one character would trigger this error:
The workaround to this before is having a separate pn.widgets.Button to submit the code, but now, users can simply watch value, or if they want to watch on every keystroke value_input
Why not have a value_throttled instead?
value_input is what other Bokeh text widgets use:
https://panel.holoviz.org/reference/widgets/TextInput.html
https://panel.holoviz.org/reference/widgets/TextAreaInput.html
I see that sliders use value_throttled.
Codecov Report
Attention: Patch coverage is 52.05479% with 35 lines in your changes missing coverage. Please review.
Project coverage is 81.75%. Comparing base (
7c90f7b) to head (c627038). Report is 67 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| panel/tests/ui/widgets/test_codeeditor.py | 37.50% | 35 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #6919 +/- ##
==========================================
- Coverage 81.79% 81.75% -0.04%
==========================================
Files 326 327 +1
Lines 48350 48421 +71
==========================================
+ Hits 39546 39587 +41
- Misses 8804 8834 +30
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This does end up being a fairly major change in behavior. I agree with it but still.
Is there a way to have a flag that reverts back to the old version to smooth the transition?
Or maybe it'd make sense to keep the current behavior with a flag that toggles the new behavior.
Is there a way to have a flag that reverts back to the old version to smooth the transition?
I think this is a good suggestion to prevent breaking changes so I have implemented a flag that de-syncs value from value_input, i.e. update value only on loss of focus / command hotkey.
Test failure seems unrelated
timeout waiting for merge ref
Oh might be https://www.githubstatus.com/
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.