mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-01 03:29:41 +08:00
🐛 fix(data-grid/table-designer/about): 修复空表横向滚动、索引编辑回显及关于弹窗按钮间距
- 空表滚动:虚拟模式下空数据表缺少 virtual-holder 元素时,回退到直接滚动表头实现横向滚动 - 索引回显:修复修改索引后再次编辑时被删除的字段仍然显示的问题,selectedIndex 随 groupedIndexes 同步更新 - 按钮间距:关于弹窗 footer 增加 flex-wrap 和 gap,解决关闭按钮与上方操作按钮行重叠 - refs #258
This commit is contained in:
@@ -3900,12 +3900,28 @@ const DataGrid: React.FC<DataGridProps> = ({
|
||||
// 虚拟表格路径:通过合成 WheelEvent 驱动 rc-virtual-list 内部状态,
|
||||
// rc-table 自动同步 header scrollLeft。
|
||||
if (enableVirtual && tableContainer instanceof HTMLElement) {
|
||||
applyVirtualHorizontalOffset(tableContainer, externalScroll.scrollLeft);
|
||||
// WheelEvent 经 rc-virtual-list 处理后状态异步更新,延迟同步 ref
|
||||
requestAnimationFrame(() => {
|
||||
lastTableScrollLeftRef.current = readVirtualHorizontalOffset(tableContainer);
|
||||
const applied = applyVirtualHorizontalOffset(tableContainer, externalScroll.scrollLeft);
|
||||
if (applied) {
|
||||
// WheelEvent 经 rc-virtual-list 处理后状态异步更新,延迟同步 ref
|
||||
requestAnimationFrame(() => {
|
||||
lastTableScrollLeftRef.current = readVirtualHorizontalOffset(tableContainer);
|
||||
horizontalSyncSourceRef.current = '';
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 空数据回退:virtual-holder 不存在时,直接滚动表头
|
||||
const headerEl = tableContainer.querySelector('.ant-table-header') as HTMLElement | null;
|
||||
const contentEl = tableContainer.querySelector('.ant-table-content') as HTMLElement | null;
|
||||
const fallbackTargets = [headerEl, contentEl].filter((el): el is HTMLElement => el instanceof HTMLElement && el.scrollWidth > el.clientWidth + 1);
|
||||
if (fallbackTargets.length > 0) {
|
||||
fallbackTargets.forEach((target) => {
|
||||
target.scrollLeft = externalScroll.scrollLeft;
|
||||
});
|
||||
lastTableScrollLeftRef.current = externalScroll.scrollLeft;
|
||||
horizontalSyncSourceRef.current = '';
|
||||
});
|
||||
return;
|
||||
}
|
||||
horizontalSyncSourceRef.current = '';
|
||||
return;
|
||||
}
|
||||
// 非虚拟表格路径:依赖 liveTargets 进行 scrollLeft 同步
|
||||
|
||||
@@ -1162,8 +1162,14 @@ ${selectedTrigger.statement}`;
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedIndex) return;
|
||||
if (!groupedIndexes.some(idx => idx.key === selectedIndex.key)) {
|
||||
const freshIndex = groupedIndexes.find(idx => idx.key === selectedIndex.key);
|
||||
if (!freshIndex) {
|
||||
setSelectedIndex(null);
|
||||
return;
|
||||
}
|
||||
// 索引仍存在但内容可能已变(如字段列表),同步为最新对象
|
||||
if (freshIndex !== selectedIndex) {
|
||||
setSelectedIndex(freshIndex);
|
||||
}
|
||||
}, [groupedIndexes, selectedIndex]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user