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

It is possible to give a widget an ID that can't be queried back #3954

Closed
davep opened this issue Jan 4, 2024 · 2 comments · Fixed by #4032
Closed

It is possible to give a widget an ID that can't be queried back #3954

davep opened this issue Jan 4, 2024 · 2 comments · Fixed by #4032
Assignees
Labels
bug Something isn't working enhancement New feature or request Task

Comments

@davep
Copy link
Collaborator

davep commented Jan 4, 2024

It is possible to give a widget an ID that can't then be queried back; for example:

from textual.app import App, ComposeResult
from textual.widgets import Label

class BadIDApp(App[None]):

    def compose(self) -> ComposeResult:
        yield Label("Hello, World!", id="foo&")

    def on_mount(self) -> None:
        self.notify(f"{self.query_one('#foo&')}")

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

Perhaps we should validate widget IDs when they are assigned?

@davep davep added bug Something isn't working enhancement New feature or request Task labels Jan 4, 2024
@willmcgugan
Copy link
Collaborator

We do this with class names, so it would be sensible to do it for IDs as well.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants