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

Setting show_root to True raises a KeyError #2363

Closed
lllama opened this issue Apr 23, 2023 · 2 comments · Fixed by #3002
Closed

Setting show_root to True raises a KeyError #2363

lllama opened this issue Apr 23, 2023 · 2 comments · Fixed by #3002
Assignees
Labels
bug Something isn't working Task

Comments

@lllama
Copy link
Contributor

lllama commented Apr 23, 2023

    def compose(self):
        dir_tree = DirectoryTree("./src/routes")
        dir_tree.show_root = True
        yield Header()
        with Horizontal():
            yield Logo()
            with TabbedContent("Config", "Routes", "Server"):
                yield Config(self.config)
                yield dir_tree
                yield Label("hello")
        yield Footer()

setting show_root to True. raises the following error:
KeyError: "No 'directory-tree--folder' key in COMPONENT_CLASSES"

Diagnose output:

Textual Diagnostics

Versions

Name Value
Textual 0.20.1
Rich 13.3.3

Python

Name Value
Version 3.11.0
Implementation CPython
Compiler Clang 14.0.0 (clang-1400.0.29.202)
Executable /Users/felixingram/Library/Application Support/hatch/env/virtual/sanic-kit/1YPPa8fF/sanic-kit/bin/python

Operating System

Name Value
System Darwin
Release 22.4.0
Version Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103

Terminal

Name Value
Terminal Application WezTerm (20230326-111934-3666303c)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=203, height=46
legacy_windows False
min_width 1
max_width 203
is_terminal False
encoding utf-8
max_height 46
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@Textualize Textualize deleted a comment from github-actions bot Apr 24, 2023
@davep
Copy link
Contributor

davep commented Apr 24, 2023

To narrow it down a wee but, this only happens if show_root is changed before the DOM is fully-loaded (for example, doing the same in on_mount is fine). Looks like watch_show_root is a bit too eager.

@davep davep added bug Something isn't working Task labels Apr 24, 2023
@davep davep self-assigned this Jul 24, 2023
davep added a commit to davep/textual that referenced this issue Jul 24, 2023
There are occasions where the Tree may want to get the label (to make size
decisions, it seems) that happen *before* a mount has finished. In
DirectoryTree component classes are being accessed but they don't come into
play until the DOM is up and running.

This change builds allows for the building of a directory tree label, while
also *not* trying to style the label, if mount hasn't finished yet.

See Textualize#2363.
davep added a commit to davep/textual that referenced this issue Jul 24, 2023
@darrenburns darrenburns assigned darrenburns and unassigned davep Oct 25, 2023
@darrenburns darrenburns removed their assignment Nov 6, 2023
Copy link

github-actions bot commented Jan 8, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

willmcgugan pushed a commit that referenced this issue Jan 11, 2024
There are occasions where the Tree may want to get the label (to make size
decisions, it seems) that happen *before* a mount has finished. In
DirectoryTree component classes are being accessed but they don't come into
play until the DOM is up and running.

This change builds allows for the building of a directory tree label, while
also *not* trying to style the label, if mount hasn't finished yet.

See #2363.
willmcgugan pushed a commit that referenced this issue Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants