mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
fix header name on unloaded row render
This commit is contained in:
@@ -866,22 +866,30 @@ export const ItemDetailList = ({
|
|||||||
const headerLeftRef = useRef<HTMLSpanElement>(null);
|
const headerLeftRef = useRef<HTMLSpanElement>(null);
|
||||||
const dataSourceRef = useRef(dataSource);
|
const dataSourceRef = useRef(dataSource);
|
||||||
dataSourceRef.current = dataSource;
|
dataSourceRef.current = dataSource;
|
||||||
|
const lastHeaderNameRef = useRef('');
|
||||||
|
|
||||||
const handleRowsRendered = useCallback(
|
const handleRowsRendered = useCallback(
|
||||||
(range: { startIndex: number; stopIndex: number }) => {
|
(range: { startIndex: number; stopIndex: number }) => {
|
||||||
const el = headerLeftRef.current;
|
const el = headerLeftRef.current;
|
||||||
if (el) {
|
if (el) {
|
||||||
const album = dataSourceRef.current[range.startIndex] as Album | undefined;
|
const album = getItem?.(range.startIndex) as Album | undefined;
|
||||||
const name = album?.name ?? '';
|
const name = album?.name ?? '';
|
||||||
|
if (name) {
|
||||||
|
lastHeaderNameRef.current = name;
|
||||||
el.textContent = name;
|
el.textContent = name;
|
||||||
el.setAttribute('data-title', name);
|
el.setAttribute('data-title', name);
|
||||||
el.title = name;
|
el.title = name;
|
||||||
|
} else {
|
||||||
|
el.textContent = lastHeaderNameRef.current;
|
||||||
|
el.setAttribute('data-title', lastHeaderNameRef.current);
|
||||||
|
el.title = lastHeaderNameRef.current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (onRangeChanged) {
|
if (onRangeChanged) {
|
||||||
onRangeChanged(range);
|
onRangeChanged(range);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[onRangeChanged],
|
[getItem, onRangeChanged],
|
||||||
);
|
);
|
||||||
|
|
||||||
const throttledHandleRowsRendered = useMemo(
|
const throttledHandleRowsRendered = useMemo(
|
||||||
|
|||||||
Reference in New Issue
Block a user