()
| 122 | let renderCallback = useRef<(() => void) | null>(null); |
| 123 | |
| 124 | let openSearchMenu = async () => { |
| 125 | if (!document.startViewTransition) { |
| 126 | setSearchOpen(prev => !prev); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | // Preload SearchMenu so it is ready to render immediately. |
| 131 | await preloadSearchMenu(); |
| 132 | |
| 133 | // Don't transition the entire page. |
| 134 | document.documentElement.style.viewTransitionName = 'none'; |
| 135 | iconRef.current!.style.viewTransitionName = 'search-menu-icon'; |
| 136 | labelRef.current!.style.viewTransitionName = 'search-menu-label'; |
| 137 | searchRef.current!.style.viewTransitionName = 'search-menu-search-field'; |
| 138 | let viewTransition = document.startViewTransition(() => { |
| 139 | // Wait until next render. Using flushSync causes flickering. |
| 140 | return new Promise<void>(resolve => { |
| 141 | iconRef.current!.style.viewTransitionName = ''; |
| 142 | labelRef.current!.style.viewTransitionName = ''; |
| 143 | searchRef.current!.style.viewTransitionName = ''; |
| 144 | renderCallback.current = resolve; |
| 145 | setSearchOpen(prev => !prev); |
| 146 | }); |
| 147 | }); |
| 148 | |
| 149 | viewTransition.finished.then(() => { |
| 150 | document.documentElement.style.viewTransitionName = ''; |
| 151 | }); |
| 152 | }; |
| 153 | |
| 154 | let closeSearchMenu = () => { |
| 155 | if (!document.startViewTransition) { |
nothing calls this directly
no test coverage detected