mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Fix mobile input prompt command selection (#148)
* fix mobile selection in suggestion dropdowns * handle mobile keyboard viewport
This commit is contained in:
1 parent
f368a2fa62
commit
a3237d7f7f
6 files changed
+61
-6
No files matched your search
@@ -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 }
|
||||
}
|
||||
Reference in new issue
Block a user