Skip to content
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

fix(tvOS:Harness): Fix focus not being visible when navigating the app on tvOS or webOS #1626

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/app-harness/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const AppContent = () => {
<NewModuleButton
ref={nativeModuleBtnRef}
onFocus={() => setFocusedIndex(0)}
onBlur={() => setFocusedIndex(null)}
onBlur={() => setFocusedIndex((prev) => (prev === 0 ? null : prev))}
style={[
styles.button,
{ backgroundColor: '#841584' },
Expand All @@ -180,7 +180,9 @@ const AppContent = () => {
isWebBased && isFactorTv && { outline: 'none' },
]}
onFocus={() => setFocusedIndex(1)}
onBlur={() => setFocusedIndex(null)}
// Sometimes onFocus may work faster than onBlue and setting
// this to null will remove focus from another item
onBlur={() => setFocusedIndex((prev) => (prev === 1 ? null : prev))}
>
<Text style={styles.buttonTitle}>Toggle Video</Text>
</TouchableOpacity>
Expand All @@ -203,7 +205,7 @@ const AppContent = () => {
isWebBased && isFactorTv && { outline: 'none' },
]}
onFocus={() => setFocusedIndex(2)}
onBlur={() => setFocusedIndex(null)}
onBlur={() => setFocusedIndex((prev) => (prev === 2 ? null : prev))}
>
<Text style={styles.buttonTitle}>Request permissions</Text>
</TouchableOpacity>
Expand Down Expand Up @@ -233,7 +235,7 @@ const AppContent = () => {
isWebBased && isFactorTv && { outline: 'none' },
]}
onFocus={() => setFocusedIndex(3)}
onBlur={() => setFocusedIndex(null)}
onBlur={() => setFocusedIndex((prev) => (prev === 3 ? null : prev))}
>
<Text style={styles.buttonTitle}>Show SplashScreen</Text>
</TouchableOpacity>
Expand All @@ -242,7 +244,7 @@ const AppContent = () => {
<PhotoEditorButton
ref={photoEditorBtnRef}
onFocus={() => setFocusedIndex(4)}
onBlur={() => setFocusedIndex(null)}
onBlur={() => setFocusedIndex((prev) => (prev === 4 ? null : prev))}
style={[
styles.button,
focusedIndex === 4 && styles.buttonFocused,
Expand Down
Loading