Fix mobile input prompt command selection (#148)

* fix mobile selection in suggestion dropdowns

* handle mobile keyboard viewport
This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-27 17:35:01 -05:00
1 parent f368a2fa62
commit a3237d7f7f
6 files changed
+61 -6

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { useState, useEffect } from 'react'
export function useVisualViewport() {
const [keyboardHeight, setKeyboardHeight] = useState(0)
useEffect(() => {
const viewport = window.visualViewport
if (!viewport) return
const update = () => {
const layoutHeight = window.innerHeight
const visualHeight = viewport.height + viewport.offsetTop
const offset = Math.max(0, layoutHeight - visualHeight)
setKeyboardHeight(offset)
}
viewport.addEventListener('resize', update)
viewport.addEventListener('scroll', update)
update()
return () => {
viewport.removeEventListener('resize', update)
viewport.removeEventListener('scroll', update)
}
}, [])
return { keyboardHeight }
}