()
| 121 | } |
| 122 | }; |
| 123 | const onScroll = () => { |
| 124 | if (Date.now() > resetUntil || window.scrollY <= 0) { |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | const input = document.activeElement as HTMLElement | null; |
| 129 | |
| 130 | if (!input || !isCodeInput(input)) { |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | const viewportHeight = |
| 135 | window.visualViewport?.height ?? window.innerHeight; |
| 136 | const { bottom } = input.getBoundingClientRect(); |
| 137 | |
| 138 | if (bottom + window.scrollY <= viewportHeight) { |
| 139 | window.scrollTo(0, 0); |
| 140 | } |
| 141 | }; |
| 142 | |
| 143 | document.addEventListener('focusin', onFocusIn); |
| 144 | window.visualViewport?.addEventListener('resize', onViewportResize); |
nothing calls this directly
no test coverage detected