-
-
Couldn't load subscription status.
- Fork 1k
Consider visible children inside invisible containers when computing focus chain #3070
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5136714
Add regression tests for #3053
rodrigogiraoserrao 70a995f
Traverse invisible containers when computing focus chain.
rodrigogiraoserrao 70ff85e
Make note of removed property.
rodrigogiraoserrao 2818817
Add regression test for #3071.
rodrigogiraoserrao 5906686
Fix #3071.
rodrigogiraoserrao 29d6b2c
Fix regression test for #3053.
rodrigogiraoserrao 242ffc1
Optimize computation of focus chain.
rodrigogiraoserrao 361ced0
Merge branch 'main' into fix-3053
rodrigogiraoserrao febbd61
Make test more robust.
rodrigogiraoserrao e9c6d5f
Make test more robust.
rodrigogiraoserrao ae773ed
Short-circuit disabled portions of DOM.
rodrigogiraoserrao 61137e9
Merge branch 'main' into fix-3053
rodrigogiraoserrao f8b270d
Simplify traversal.
rodrigogiraoserrao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| from textual.app import App, ComposeResult | ||
| from textual.containers import VerticalScroll | ||
| from textual.widget import Widget | ||
|
|
||
|
|
||
| async def test_visibility_changes() -> None: | ||
| """Test changing visibility via code and CSS. | ||
|
|
||
| See https://github.com/Textualize/textual/issues/1355 as the motivation for these tests. | ||
| """ | ||
|
|
||
| class VisibleTester(App[None]): | ||
| """An app for testing visibility changes.""" | ||
|
|
||
| CSS = """ | ||
| Widget { | ||
| height: 1fr; | ||
| } | ||
| .hidden { | ||
| visibility: hidden; | ||
| } | ||
| """ | ||
|
|
||
| def compose(self) -> ComposeResult: | ||
| yield VerticalScroll( | ||
| Widget(id="keep"), Widget(id="hide-via-code"), Widget(id="hide-via-css") | ||
| ) | ||
|
|
||
| async with VisibleTester().run_test() as pilot: | ||
| assert pilot.app.query_one("#keep").visible is True | ||
| assert pilot.app.query_one("#hide-via-code").visible is True | ||
| assert pilot.app.query_one("#hide-via-css").visible is True | ||
|
|
||
| pilot.app.query_one("#hide-via-code").styles.visibility = "hidden" | ||
| await pilot.pause(0) | ||
| assert pilot.app.query_one("#keep").visible is True | ||
| assert pilot.app.query_one("#hide-via-code").visible is False | ||
| assert pilot.app.query_one("#hide-via-css").visible is True | ||
|
|
||
| pilot.app.query_one("#hide-via-css").set_class(True, "hidden") | ||
| await pilot.pause(0) | ||
| assert pilot.app.query_one("#keep").visible is True | ||
| assert pilot.app.query_one("#hide-via-code").visible is False | ||
| assert pilot.app.query_one("#hide-via-css").visible is False | ||
|
|
||
|
|
||
| async def test_visible_is_inherited() -> None: | ||
| """Regression test for https://github.com/Textualize/textual/issues/3071""" | ||
|
|
||
| class InheritedVisibilityApp(App[None]): | ||
| CSS = """ | ||
| #four { | ||
| visibility: visible; | ||
| } | ||
|
|
||
| #six { | ||
| visibility: hidden; | ||
| } | ||
| """ | ||
|
|
||
| def compose(self): | ||
| yield Widget(id="one") | ||
| with VerticalScroll(id="two"): | ||
| yield Widget(id="three") | ||
| with VerticalScroll(id="four"): | ||
| yield Widget(id="five") | ||
| with VerticalScroll(id="six"): | ||
| yield Widget(id="seven") | ||
|
|
||
| app = InheritedVisibilityApp() | ||
| async with app.run_test(): | ||
| assert app.query_one("#one").visible | ||
| assert app.query_one("#two").visible | ||
| assert app.query_one("#three").visible | ||
| assert app.query_one("#four").visible | ||
| assert app.query_one("#five").visible | ||
| assert not app.query_one("#six").visible | ||
| assert not app.query_one("#seven").visible |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.