Improve DiscoverVideoEpisodeCell focus handling#4581
Open
SergioEstevao wants to merge 3 commits into
Open
Conversation
This avoid focus conflicts when moving quickly around cells
Follow-up cleanup to the focus refactor. Removes dead state left over from the old expand()/collapse()/placeholderFocusView machinery (lastFocusedButton, isContainerFocused, isAnimating), drops a redundant top-level ZStack and a Group wrapper, and extracts the repeated 1x1-frame focus trick into a documented collapsedWhenUnfocused(_:) helper. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors DiscoverVideoEpisodeCell (tvOS Discover video episode card) to simplify focus-handling code and reduce view-tree noise after a prior focus refactor.
Changes:
- Removes unused focus/animation state and the old expand/collapse placeholder-focus machinery.
- Simplifies the view hierarchy by removing redundant wrappers and always layering focused/non-focused content together.
- Extracts the “1×1 when unfocused” focus-chain trick into a documented
collapsedWhenUnfocused(_:)view helper.
Comment on lines
+48
to
51
| ZStack { | ||
| focusedContent | ||
| nonFocusedContent | ||
| } |
| collapse() | ||
| } | ||
| } | ||
| .animation(.snappy, value: isFocused) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Change how the focus on discover video episode cell is handled so focus conflicts are avoided when moving around quickly on the row
What changed:
expand()/collapse()/placeholderFocusViewmachinery:lastFocusedButton,isContainerFocused, andisAnimating(each was declaration-only, never read or written).ZStackthat wrapped a singleVStack, and a redundantGroupwrapper around the singleHStackinnonFocusedContent..frame(width: isFocused ? nil : 1, height: isFocused ? nil : 1)trick into a documentedcollapsedWhenUnfocused(_:)view helper that explains why the 1×1 frame exists (keeping buttons in the tvOS focus chain while visually hidden).Why: reduces noise and clarifies the intent of the focus trick so the cell is easier to maintain.
To test
Checklist
CHANGELOG.mdif necessary.🤖 Generated with Claude Code