Skip to content

fix: prevent KeyError on TextArea theme initialization (#6528)#6553

Open
marcos-dataops wants to merge 1 commit into
Textualize:mainfrom
marcos-dataops:fix-6528-textarea-theme
Open

fix: prevent KeyError on TextArea theme initialization (#6528)#6553
marcos-dataops wants to merge 1 commit into
Textualize:mainfrom
marcos-dataops:fix-6528-textarea-theme

Conversation

@marcos-dataops
Copy link
Copy Markdown

Thank you for contributing!

This project requires all PRs to link to an issue or discussion. Ideally signed off by @willmcgugan

Link to issue or discussion
Closes #6528


Hey folks! Ran into a crash when throwing a TextArea inside a ModalScreen. It throws a KeyError looking for text-area--gutter in the component styles because it tries to render before the DOM has fully resolved the initial component classes.

To fix this without breaking the render cycle, I just wrapped the get_component_rich_style call inside apply_css with a try/except. If the key isn't there yet, it safely falls back to None and continues smoothly.

I also dropped a quick regression test in test_issue_6528.py to make sure we don't catch this crash again in the future.

Let me know if you need any adjustments to this approach. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextArea modal crashes: KeyError 'text-area--gutter' in apply_css (8.2.x)

1 participant