-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Disabled container #2776
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
Disabled container #2776
Conversation
willmcgugan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can save a few cpu cycles here.
src/textual/widget.py
Outdated
| if ( | ||
| self.disabled | ||
| and self.app.focused is not None | ||
| and self.app.focused in self.walk_children() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is somewhat inefficient to walk the DOM every time something is disabled.
How about we just check if self.app.focused is disabled or has a disabled ancestor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 as in a45b156?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that looks right to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the tests don't like it. Why does this require a screen on the stack..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@willmcgugan I'd say you have to check if the optimisation is worth the extra mess created to handle the cases where the disabled status is set outside the context of a running app.
Related comments: #2776 (comment)
This fixes #2772 by blurring the focused widget if it is a descendant of the widget that was disabled.