fix: 由於未知原因導致的 輸入框 逃竄到 Tab 的 change 事件, 造成 Tab Panel 顯示異常
This commit is contained in:
@@ -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%',
|
||||||
|
|||||||
Reference in New Issue
Block a user