Set a controlled widget back after an event that caused a render - #62
Closed
maartenbreddels wants to merge 1 commit into
Closed
maartenbreddels wants to merge 1 commit into
maartenbreddels wants to merge 1 commit into
Conversation
When the user changes a widget whose element gives the value (value=X, on_value=h), and h changes state so that a render happens, the default renderer sets every widget in the tree back to its element's values, because it walks the whole tree. The fast renderer skips components that did not change. So when h leaves its own state as it is (it upper-cases "Bb" to the "BB" we already have) but changes other state, the widget kept showing "Bb" while the state was "BB", only in the fast renderer. That is a case of vuejs/vue#13237. The event listener now remembers the element that currently owns the widget, and after a handler that caused a render, it sets the trait back to that element's value. That gives the fast renderer the result of the default renderer. A listener that the render replaced does nothing, since the new element has already been applied. When nothing rendered, the widget keeps what the user entered, in both renderers, as before. A first version always set it back (like React, and like #45), but solara's inputs with continuous_update=False depend on this: they pass the old value, ignore v_model changes, and take the new value on blur. With a write-back, typing snapped back on every key. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
maartenbreddels
force-pushed
the
fix/fast-event-writeback
branch
from
September 28, 2026 13:16
e0b9397 to
9818c67
Compare
Contributor
Author
|
not worth a performance hit maybe? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Take a controlled widget, where the element gives the value and a handler maps the new value to state:
Type "Bb": the handler sets "BB", which is the state we already have, and it changes the count, so a render happens.
REACTON_FAST=1) skips the component that did not change, so the text keeps showing "Bb" while the state is "BB".This is a case of vuejs/vue#13237.
What
The event listener is now a small class,
_TraitListener, that remembers the element that currently owns the widget. That element is updated when a new element keeps the same callback. After a handler that caused a render, the listener sets the trait back to that element's value. So the fast renderer now gives the default renderer's result.When nothing rendered, nothing changes, in both renderers. A first version always set the widget back, like React and like #45. That broke 5 of solara's
input_test.pytests:InputInt/InputFloatwithcontinuous_update=Falsepass the old value, ignorev_modelchanges while you type, and take the new value on blur, so every keystroke snapped back. Fixing the no-render case needs a change in solara first.Tests
In both renderers:
test_controlled_widget_no_state_change_sibling_renders[layout]andtest_controlled_widget_no_state_change_parent_renders: fail on master in the fast renderer, pass in the default renderer.test_controlled_widget_same_callback_new_value: the callback is the same object on every render, so the value set back must come from the new element.test_controlled_widget_no_render_keeps_user_value: pins the solaracontinuous_update=Falsebehavior.test_uncontrolled_widget_keeps_its_value,test_controlled_widget_removed_by_handler: guard tests.REACTON_FAST=0and=1.🤖 Generated with Claude Code