fix: 由於未知原因導致的 輸入框 逃竄到 Tab 的 change 事件, 造成 Tab Panel 顯示異常

This commit is contained in:
CrescentLeaf
2025-09-20 17:35:12 +08:00
parent c82d718fa7
commit af9b0d7cf2

View File

@@ -21,9 +21,9 @@ export default function ChatFragment({ target, ...props }: Args) {
} as Chat) } as Chat)
const [tabItemSelected, setTabItemSelected] = React.useState('Chat') const [tabItemSelected, setTabItemSelected] = React.useState('Chat')
const tabRef: React.MutableRefObject<Tab | null> = React.useRef(null) const tabRef = React.useRef<Tab>(null)
useEventListener(tabRef, 'change', (event) => { useEventListener(tabRef, 'change', () => {
setTabItemSelected((event.target as HTMLElement as Tab).value as string) setTabItemSelected(tabRef.current?.value || "Chat")
}) })
React.useEffect(() => { React.useEffect(() => {
@@ -38,6 +38,7 @@ export default function ChatFragment({ target, ...props }: Args) {
})() })()
}, [target]) }, [target])
console.log(tabItemSelected)
return ( return (
<div style={{ <div style={{
width: '100%', width: '100%',