Skip to content

Fix SelectCurrent update before #label is composed#6599

Open
VedK5643 wants to merge 1 commit into
Textualize:mainfrom
VedK5643:fix/selectcurrent-before-mount
Open

Fix SelectCurrent update before #label is composed#6599
VedK5643 wants to merge 1 commit into
Textualize:mainfrom
VedK5643:fix/selectcurrent-before-mount

Conversation

@VedK5643

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

#6581

Summary

Fixes #6581.

This PR fixes a crash that can occur when SelectCurrent.update() is invoked before the widget has composed its #label child.

The crash occurs because query_one("#label") raises NoMatches during early widget initialization.

This change preserves the pending label state until composition and adds a regression test covering the issue.

Changes

  • Handle NoMatches when #label is not yet available.
  • Initialize the composed label using the stored label value.
  • Add a regression test reproducing the issue.

Testing

  • Added a regression test for the reported crash.
  • Verified the test fails on the original implementation.
  • Verified the test passes with the fix.
  • Ran the existing Select test suite successfully.

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.

Select can crash during mount: SelectCurrent.update() queries #label before it is mounted (NoMatches)

1 participant