Textualize/textual · error · ScreenError
Can't make {self} active as it is not in the current stack.
Error message
Can't make {self} active as it is not in the current stack. What it means
pop_until_active tries to pop the screen stack down to this screen, but the underlying App._pop_to_screen failed, meaning this screen instance is not in the active stack.
Source
Thrown at src/textual/screen.py:2096
await_pop.set_pre_await_callback(pre_await)
return await_pop
def pop_until_active(self) -> None:
"""Pop any screens on top of this one, until this screen is active.
Raises:
ScreenError: If this screen is not in the current mode.
"""
from textual.app import ScreenError
try:
self.app._pop_to_screen(self)
except ScreenError:
# More specific error message
raise ScreenError(
f"Can't make {self} active as it is not in the current stack."
) from None
async def action_dismiss(self, result: ScreenResultType | None = None) -> None:
"""A wrapper around [`dismiss`][textual.screen.Screen.dismiss] that can be called as an action.
Args:
result: The optional result to be passed to the result callback.
"""
await self._flush_next_callbacks()
self.dismiss(result)
def can_view_entire(self, widget: Widget) -> bool:
"""Check if a given widget is fully within the current screen.
Note: This doesn't necessarily equate to a widget being visible.
There are other reasons why a widget may not be visible.
View on GitHub (pinned to 06dbeef4bb)
Solutions
- Re-create and push the screen instead of reusing a dismissed instance
- Check 'self in self.app.screen_stack' before calling
- Use app.switch_screen() for replacing the base screen
Example fix
# before self.old_screen.pop_until_active() # stale reference # after self.app.switch_screen(MainScreen())
Defensive patterns
Strategy: validation
Validate before calling
if self in self.app.screen_stack:
self.pop_until_active() Try / catch
from textual.app import ScreenError
try:
screen.pop_until_active()
except ScreenError:
app.switch_screen(screen.__class__()) Prevention
- Do not retain references to dismissed screens
- Re-push fresh screen instances for navigation
When it happens
Trigger: Calling screen.pop_until_active() (usually via the make_base_active action) on a screen that was already dismissed, never pushed, or was removed from the stack.
Common situations: Holding a stale reference to a dismissed modal and re-triggering navigation to it; calling the action after the screen stack changed asynchronously.
Related errors
- node has no screen
- Can't await screen.dismiss() from the screen's message handl
- Can't animate attribute {attribute!r} on {obj!r}; attribute
- Don't know how to animate {value!r}; Can only animate <int>,
- Can't encode {datum!r}
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/73d5725f411c26a2.
Report an issue: GitHub.