按当前筛选后的完整已载入顺序切换,边界自动禁用,后台续页到达后自动开放。 独立保存选中目标以支持加载及失败时切换,沿用取消/迟到响应隔离,关闭返回原表格焦点。 验证:详情首中尾/未知目标、加载/失败、100到101续页先红后绿;既有流水和看板范围回归、完整门禁及原生备份恢复通过。
This commit is contained in:
@@ -52,6 +52,7 @@ interface ViewProps {
|
||||
loading: boolean
|
||||
error: string | null
|
||||
detail: QARecord | null
|
||||
detailID?: string | null
|
||||
detailLoading: boolean
|
||||
detailError: string | null
|
||||
onSelect: (id: string) => void
|
||||
@@ -176,6 +177,9 @@ export function QAOperationsView(props: ViewProps) {
|
||||
return map
|
||||
}, [props.taskUpdates])
|
||||
const detail = props.detail
|
||||
const detailIndex = page?.items.findIndex((item) => item.id === (props.detailID ?? detail?.id)) ?? -1
|
||||
const previous = detailIndex > 0 ? page?.items[detailIndex - 1] : undefined
|
||||
const next = detailIndex >= 0 ? page?.items[detailIndex + 1] : undefined
|
||||
const showDrawer = Boolean(detail || props.detailLoading || props.detailError)
|
||||
return (
|
||||
<section className="qa-ops-results" aria-label="问答记录">
|
||||
@@ -320,9 +324,17 @@ export function QAOperationsView(props: ViewProps) {
|
||||
>
|
||||
<header>
|
||||
<h3>问答详情</h3>
|
||||
<button type="button" autoFocus onClick={props.onCloseDetail}>
|
||||
关闭详情
|
||||
</button>
|
||||
<div className="qa-detail-actions">
|
||||
<button type="button" disabled={!previous} onClick={() => previous && props.onSelect(previous.id)}>
|
||||
上一条
|
||||
</button>
|
||||
<button type="button" disabled={!next} onClick={() => next && props.onSelect(next.id)}>
|
||||
下一条
|
||||
</button>
|
||||
<button type="button" autoFocus onClick={props.onCloseDetail}>
|
||||
关闭详情
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
{detail ? (
|
||||
<QAInlineFields
|
||||
@@ -431,6 +443,7 @@ export function QAOperations() {
|
||||
viewRef.current = view
|
||||
const [mirrorChanged, setMirrorChanged] = useState(false)
|
||||
const [detail, setDetail] = useState<QARecord | null>(null)
|
||||
const [detailID, setDetailID] = useState<string | null>(null)
|
||||
const [detailLoading, setDetailLoading] = useState(false)
|
||||
const [detailError, setDetailError] = useState<string | null>(null)
|
||||
const [progress, setProgress] = useState<{ loaded: number; total: number } | undefined>()
|
||||
@@ -454,6 +467,7 @@ export function QAOperations() {
|
||||
setError(null)
|
||||
detailRequest.current?.abort()
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
return
|
||||
}
|
||||
const controller = new AbortController()
|
||||
@@ -465,6 +479,7 @@ export function QAOperations() {
|
||||
setPage(null)
|
||||
setProgress(undefined)
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(false)
|
||||
void fetchQAStatus(controller.signal)
|
||||
@@ -547,9 +562,11 @@ export function QAOperations() {
|
||||
}, [])
|
||||
const select = useCallback(async (id: string) => {
|
||||
detailRequest.current?.abort()
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
if (!document.activeElement?.closest('.qa-ops-drawer'))
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
const controller = new AbortController()
|
||||
detailRequest.current = controller
|
||||
setDetailID(id)
|
||||
setDetail(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(true)
|
||||
@@ -585,6 +602,7 @@ export function QAOperations() {
|
||||
}
|
||||
detailRequest.current?.abort()
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(false)
|
||||
returnFocus.current?.focus()
|
||||
@@ -728,6 +746,7 @@ export function QAOperations() {
|
||||
error={error}
|
||||
loading={loading}
|
||||
detail={detail}
|
||||
detailID={detailID}
|
||||
detailLoading={detailLoading}
|
||||
detailError={detailError}
|
||||
onReloadDetail={() => {
|
||||
|
||||
Reference in New Issue
Block a user