Skip to content

Fix KeyError and color blending crash on custom TextAreas#6595

Open
amanparab1 wants to merge 1 commit into
Textualize:mainfrom
amanparab1:fix-textarea-modal-keyerror
Open

Fix KeyError and color blending crash on custom TextAreas#6595
amanparab1 wants to merge 1 commit into
Textualize:mainfrom
amanparab1:fix-textarea-modal-keyerror

Conversation

@amanparab1

Copy link
Copy Markdown

This Pull Request resolves two crashes associated with the TextArea widget:

  1. KeyError in apply_css: Mounting or rendering a custom TextArea subclass with overridden or empty COMPONENT_CLASSES raised KeyError: "No 'text-area--gutter' key in COMPONENT_CLASSES". This happened because TextAreaTheme.apply_css called get_component_rich_style() directly without safety checks. This is resolved by wrapping style retrieval in a try-except block to return None on missing classes rather than crashing.
  2. AttributeError in color blending: In the selection style fallback code, app_theme.primary (a string) was passed directly to background_color.blend(), which expects a Color object, raising AttributeError: 'str' object has no attribute 'auto'. This is fixed by wrapping the string in Color.parse().

Fixes

Fixes #6528

Verification

Added a unit test under tests/text_area/test_issue_6528.py that verifies TextArea subclassing with overridden component classes mounts and resolves styles correctly without crashes.

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