Skip to content

Compositor map not aware of widgets nested deep into the DOM on app startup #2254

@rodrigogiraoserrao

Description

@rodrigogiraoserrao

When working on #2031 we realised that there is an issue with the compositor _full_map on app startup, in that it does not contain the widgets that are nested within the DOM.

To reproduce:

  1. Run the app below and connect to the console.
  2. Press P after app startup and note the size of the map that is printed.
  3. Scroll the app to the very bottom.
  4. Press P again.
  5. Notice that the map that was printed now is significantly bigger.
App
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Label


class MyApp(App[None]):
    def compose(self) -> ComposeResult:
        with VerticalScroll():
            yield Label("v\n" * 500)
            with VerticalScroll():
                for i in range(15):
                    yield Label(str(i))
                with VerticalScroll():
                    for i in range(35):
                        yield Label(str(i))

    def key_p(self) -> None:
        print(self.screen._compositor._full_map)


if __name__ == "__main__":
    MyApp().run()

Metadata

Metadata

Assignees

Labels

TaskbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions