Repository navigation
fix(explore): stop the search keyboard flashing dark and smooth the search transition #34575
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
vinnyhoward
merged 3 commits into
main
from
fix-tmcu-1261-search-keyboard-and-transition
Aug 11, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
121 changes: 121 additions & 0 deletions
121
app/components/hooks/useScreenTransitionComplete.test.ts
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,121 @@ | ||
| import { renderHook, act } from '@testing-library/react-native'; | ||
| import { | ||
| SCREEN_TRANSITION_FALLBACK_MS, | ||
| useScreenTransitionComplete, | ||
| } from './useScreenTransitionComplete'; | ||
|
|
||
| type TransitionEndListener = (event: { data: { closing: boolean } }) => void; | ||
| type FocusListener = () => void; | ||
|
|
||
| const mockUnsubscribe = jest.fn(); | ||
| const mockIsFocused = jest.fn(() => true); | ||
| let transitionListener: TransitionEndListener | undefined; | ||
| let focusListener: FocusListener | undefined; | ||
|
|
||
| const mockAddListener = jest.fn( | ||
| (eventName: string, listener: TransitionEndListener & FocusListener) => { | ||
| if (eventName === 'transitionEnd') { | ||
| transitionListener = listener; | ||
| } | ||
| if (eventName === 'focus') { | ||
| focusListener = listener; | ||
| } | ||
| return mockUnsubscribe; | ||
| }, | ||
| ); | ||
|
|
||
| jest.mock('@react-navigation/native', () => ({ | ||
| useNavigation: () => ({ | ||
| addListener: mockAddListener, | ||
| isFocused: mockIsFocused, | ||
| }), | ||
| })); | ||
|
|
||
| describe('useScreenTransitionComplete', () => { | ||
| beforeEach(() => { | ||
| jest.useFakeTimers(); | ||
| jest.clearAllMocks(); | ||
| mockIsFocused.mockReturnValue(true); | ||
| transitionListener = undefined; | ||
| focusListener = undefined; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| it('returns false before the transition ends', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('returns true when the opening transition ends', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| act(() => transitionListener?.({ data: { closing: false } })); | ||
|
|
||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('stays false when the transition belongs to the screen closing', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| act(() => transitionListener?.({ data: { closing: true } })); | ||
|
|
||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('returns true after the fallback delay when no event is emitted', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| act(() => { | ||
| jest.advanceTimersByTime(SCREEN_TRANSITION_FALLBACK_MS); | ||
| }); | ||
|
|
||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('stays false when the fallback fires after the screen lost focus', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| // The screen is dismissed before its opening transition ever ends, so it is | ||
| // animating out while still mounted. | ||
| mockIsFocused.mockReturnValue(false); | ||
| act(() => { | ||
| jest.advanceTimersByTime(SCREEN_TRANSITION_FALLBACK_MS); | ||
| }); | ||
|
|
||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('re-arms the fallback when the screen comes back into focus', () => { | ||
| const { result } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| mockIsFocused.mockReturnValue(false); | ||
| act(() => { | ||
| jest.advanceTimersByTime(SCREEN_TRANSITION_FALLBACK_MS); | ||
| }); | ||
| expect(result.current).toBe(false); | ||
|
|
||
| mockIsFocused.mockReturnValue(true); | ||
| act(() => focusListener?.()); | ||
| act(() => { | ||
| jest.advanceTimersByTime(SCREEN_TRANSITION_FALLBACK_MS); | ||
| }); | ||
|
|
||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('clears the fallback timer and both listeners on unmount', () => { | ||
| const { unmount } = renderHook(() => useScreenTransitionComplete()); | ||
|
|
||
| unmount(); | ||
|
|
||
| expect(mockUnsubscribe).toHaveBeenCalledTimes(2); | ||
| // The pending fallback must not fire a state update on the unmounted hook. | ||
| act(() => { | ||
| jest.advanceTimersByTime(SCREEN_TRANSITION_FALLBACK_MS); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.