Skip to content
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

on_leave event being fired by widget in inactive screen #4630

Closed
kwevin opened this issue Jun 9, 2024 · 5 comments · Fixed by #4688
Closed

on_leave event being fired by widget in inactive screen #4630

kwevin opened this issue Jun 9, 2024 · 5 comments · Fixed by #4688

Comments

@kwevin
Copy link

kwevin commented Jun 9, 2024

Occurs in version v0.63 and v0.66

Textual Diagnostics

Versions

Name Value
Textual 0.63.0
Rich 13.7.1

Python

Name Value
Version 3.11.1
Implementation CPython
Compiler MSC v.1934 64 bit (AMD64)
Executable C:\Users\Kevin\AppData\Local\pypoetry\Cache\virtualenvs\listentui-qruDwX8r-py3.11\Scripts\python.exe

Operating System

Name Value
System Windows
Release 10
Version 10.0.22621

Terminal

Name Value
Terminal Application Windows Terminal
TERM Not set
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=171, height=30
legacy_windows False
min_width 1
max_width 171
is_terminal True
encoding utf-8
max_height 30
justify None
overflow None
no_wrap False
highlight None
markup None
height None

on_leave event is being fired despite staying within the widget. This only started happening after updating to v0.63.0 from v0.62.0. I've attempted to narrow down the issue and found out that widgets or tasks from an inactive screen was causing the issue.

example.mp4

Here is how the screen is pushed.
And by commenting out the widgets in tabbed content at main.py (the main screen) and pushing a test screen, the issue doesn't appear. if the test screen was pushed with all the tabbed content widget it would repeatedly fire _on_leave like in the example video.

Here is a demonstration of what I am talking about.

my_testing.mp4

All the code can be found at https://github.com/kwevin/LISTEN.tui/tree/mre in the mre branch
To run my repository, you would need libmpv to be in your PATH or env variable. Guide here.

Thank you.

@Textualize Textualize deleted a comment from github-actions bot Jun 9, 2024
@charles-001
Copy link

+1 this issue affects me as well

@willmcgugan
Copy link
Collaborator

I'm going to need an MRE for this. If I can't reproduce it, I'm working blind.

If you can reproduce it in your app, I would suggest removing things until it goes away.

Check that whatever is under cursor isn't actually changing. Are you recomposing? That will cause a leave. Ditto if you setting the loading flag on a widget, that will cause a leave event because the loading indicator is now under the mouse.

Are you using workers? Any threads?

Basically, I need something to work with.

@kwevin
Copy link
Author

kwevin commented Jun 24, 2024

I tried to recreate the issue with an MRE but i have no luck in doing so. Though I've narrowed down the issue to be a widget in an inactive screen I don't still know what cause the issues.

Are you recomposing?

It is using reactive to change the content when hovered over. But by commenting out the widgets in another screen the issue was resolved.

Are you using workers? Any threads?

No workers or threads are used to push the screen. There are normal worker and threaded worker running in the background.

The screen stack I currently have looks like this:

App
   |
Main(Screen) <-- caused by some widget here
   |
Popup(Screen) <-- issue happens here

By commenting out the widgets in my Main screen the issue in the popup screen disappear. This also only started happening after upgrading to v0.63.0. I'll try to narrow down what is causing it, but so far recreating the situation under and MRE seems to not have work.

@charles-001
Copy link

charles-001 commented Jun 28, 2024

@willmcgugan - I seemed to have successfully created an MRE. The issue with the code attached is:

tab.dashboard_container.display = False
tab.loading_indicator.display = False
tab.progressbar.display = False
tab.additional_info.display = False
tab.line.display = False

It seems from v0.63.0 and onwards, this type of code is problematic.

mre.py.zip

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants