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