ui: 修正 Tab 指示標顯示不正常
This commit is contained in:
@@ -41,11 +41,11 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
title: '加載中...'
|
title: '加載中...'
|
||||||
} as Chat)
|
} as Chat)
|
||||||
|
|
||||||
const [tabItemSelected, setTabItemSelected] = React.useState('Chat')
|
const [tabItemSelected, setTabItemSelected] = React.useState('None')
|
||||||
const tabRef = React.useRef<Tab>(null)
|
const tabRef = React.useRef<Tab>(null)
|
||||||
const chatPanelRef = React.useRef<HTMLElement>(null)
|
const chatPanelRef = React.useRef<HTMLElement>(null)
|
||||||
useEventListener(tabRef, 'change', () => {
|
useEventListener(tabRef, 'change', () => {
|
||||||
setTabItemSelected(tabRef.current?.value || "Chat")
|
tabRef.current != null && setTabItemSelected(tabRef.current!.value as string)
|
||||||
})
|
})
|
||||||
|
|
||||||
useAsyncEffect(async () => {
|
useAsyncEffect(async () => {
|
||||||
@@ -57,7 +57,15 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
return checkApiSuccessOrSncakbar(re, "對話錯誤")
|
return checkApiSuccessOrSncakbar(re, "對話錯誤")
|
||||||
setChatInfo(re.data as Chat)
|
setChatInfo(re.data as Chat)
|
||||||
|
|
||||||
loadMore()
|
await loadMore()
|
||||||
|
|
||||||
|
setTabItemSelected("Chat")
|
||||||
|
setTimeout(() => {
|
||||||
|
chatPanelRef.current!.scrollTo({
|
||||||
|
top: 10000000000,
|
||||||
|
behavior: "smooth",
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
}, [target])
|
}, [target])
|
||||||
|
|
||||||
const page = React.useRef(0)
|
const page = React.useRef(0)
|
||||||
@@ -131,7 +139,7 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
}} {...props}>
|
}} {...props}>
|
||||||
<mdui-tabs ref={tabRef} value="Chat" style={{
|
<mdui-tabs ref={tabRef} value={tabItemSelected} style={{
|
||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
@@ -148,6 +156,7 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
chatInfo.title
|
chatInfo.title
|
||||||
}</mdui-tab>
|
}</mdui-tab>
|
||||||
<mdui-tab value="Settings">設定</mdui-tab>
|
<mdui-tab value="Settings">設定</mdui-tab>
|
||||||
|
<mdui-tab value="None" style={{ display: 'none' }}></mdui-tab>
|
||||||
|
|
||||||
<mdui-tab-panel slot="panel" value="Chat" ref={chatPanelRef} style={{
|
<mdui-tab-panel slot="panel" value="Chat" ref={chatPanelRef} style={{
|
||||||
display: tabItemSelected == "Chat" ? "flex" : "none",
|
display: tabItemSelected == "Chat" ? "flex" : "none",
|
||||||
@@ -255,6 +264,8 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
}}>
|
}}>
|
||||||
Work in progress...
|
Work in progress...
|
||||||
</mdui-tab-panel>
|
</mdui-tab-panel>
|
||||||
|
<mdui-tab-panel slot="panel" value="None">
|
||||||
|
</mdui-tab-panel>
|
||||||
</mdui-tabs>
|
</mdui-tabs>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user