-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schedule reactive callbacks on watcher. #3065
Conversation
The async reactive callbacks are now scheduled on the message pump of the watcher of the reactive instead of on the owner of the reactive attribute. Related issues: #3036.
Had some additional thoughts about this. We're posting a callback message which will result the callback running after all other messages. On reflection, there is need to wait for that. We have a |
@willmcgugan the reasoning makes sense to me, but the tests didn't like it. It breaks |
Nothing comes to mind. What was the error? |
The with input.prevent(Input.Changed):
input.value = "bar" The code above will still post the input changed event. Full error: async def test_prevent() -> None:
app = PreventTestApp()
async with app.run_test() as pilot:
assert not app.input_changed_events
input = app.query_one(Input)
input.value = "foo"
await pilot.pause()
assert len(app.input_changed_events) == 1
assert app.input_changed_events[0].value == "foo"
with input.prevent(Input.Changed):
input.value = "bar"
await pilot.pause()
> assert len(app.input_changed_events) == 1
E AssertionError: assert 2 == 1
E + where 2 = len([Input.Changed(input=Input(), value='foo', validation_result=None), Input.Changed(input=Input(), value='bar', validation_result=None)])
E + where [Input.Changed(input=Input(), value='foo', validation_result=None), Input.Changed(input=Input(), value='bar', validation_result=None)] = PreventTestApp(title='PreventTestApp', classes={'-dark-mode'}).input_changed_events
tests/test_message_pump.py:88: AssertionError |
I might be reading this incorrectly, but it looks like the By using |
Ah. You might want to investigate if |
I was looking at it. |
I investigated further and what's happening is much more interesting and nuanced than what I first thought. Premise: I think yes, Reasoning: My experiments actually showed cases where using The case in point is the test textual/tests/test_message_pump.py Lines 84 to 85 in 1270b8d
When we use |
I think we should If prevent isn't working with |
So, what you are saying is that I'll be happy to chat about it tomorrow, if you want. |
Fix CHANGELOG.md in the process.
Provides a regression test for #3166.
Related issue: #3166.
Related review comment: #3065 (comment).
@willmcgugan Feel free to review. |
@rodrigogiraoserrao would you mind resolve the CHANGELOG |
Done. I'll wait for tests and then merge. |
The async reactive callbacks are now scheduled on the message pump of the watcher of the reactive instead of on the owner of the reactive attribute. Related issues: #3036.