Closed darrenburns closed 3 months ago
I was calling self.recompose
inside on_resize
inside the Screen I was pushing. This fails if there's a notification on screen as the first resize event arrives too early. I just put a block in to prevent it running on the first resize event and it works as expect.
I suspect that is down to the call to self.app._refresh_notifications()
in on_screen_resume
. If that was awaited, it could fix it.
Could you try for an MRE again? I suspect it will be a matter of just repeating things very fast.
Press n
and then p
:
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.screen import ModalScreen
from textual.widgets import Footer, Label
class MyScreen(ModalScreen[None]):
def compose(self) -> ComposeResult:
yield Label("MyScreen")
async def on_resize(self) -> None:
await self.recompose()
class MountCrash(App[None]):
BINDINGS = [
Binding("p", "push", "Push a new screen"),
Binding("n", "notification", "Notification"),
]
def compose(self) -> ComposeResult:
yield Label("App")
yield Footer()
def action_notification(self) -> None:
self.notify("Hello, world!", title="Notification message", timeout=10)
async def action_push(self) -> None:
await self.push_screen(MyScreen(), callback=lambda _: None)
app = MountCrash()
if __name__ == "__main__":
app.run()
I think that's related to: https://github.com/Textualize/textual/issues/4570 (see the last MRE of my last response - it also happens on screen change, but pop_screen in my case)
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
Unfortunately, the latest change in locks seems does not fix any of my issues mentioned in the linked (closed) issue #4570.
Could I ask you @darrenburns to take a look at this, please? Maybe you'll notice something right away, and I have some problems shown there (in MREs), like this mounting error and even the application freeze.
Please do not comment on closed issues. We need an open issue to track tasks.
There's no need to mention any particular dev.
I haven't been able to isolate an MRE for this. It works if I clear the notifications before I push my modal screen.
More details below:
Details