Skip to content

fix(layout): 拖拽松手后底边栏不再闪全宽 (#258) - #259

Merged
Menghuan1918 merged 1 commit into
mainfrom
fix/bottom-panel-width-flash
Aug 20, 2026
Merged

fix(layout): 拖拽松手后底边栏不再闪全宽 (#258)#259
Menghuan1918 merged 1 commit into
mainfrom
fix/bottom-panel-width-flash

Conversation

@Menghuan1918

Copy link
Copy Markdown
Collaborator

问题

每次拖动右侧栏(宽度)松手后,底边栏先瞬间变成全宽(盖过右侧栏),然后约 300ms 动画滑回新的正确宽度。#258

根因

松手时 store 提交宽度 → 布局推挤 effect(--dsh-sidebar-width/height 写入)依赖变化 → 其 cleanup 会 removeProperty 推挤变量。React 被动 effect flush 的 cleanup 与 setup 之间会让出渲染帧(逐帧采样证实):浏览器先绘制出「推挤已释放」的布局(#root margin 0、中心列全宽,且 data-dsh-sidebar-dragging 已移除、margin 过渡重新启用),随后 setup 重写变量 → #root margin-right 从 0 过渡动画回新宽度;同一间隙中拖拽结束的 measureCenter 缓存了全宽的中心列 rect → 底边栏被渲染成全宽,再被 ResizeObserver 逐帧跟随动画修正。

修复

推挤变量的清理拆成 unmount-only effect:挂载期间变量持续有效,不存在可被绘制/测量到的推挤释放窗口;卸载(RenderBoundary 崩溃替换 / HMR fiber 释放)时仍释放推挤,保持 issue #31 的保证。

测试

  • 新增 e2e(drag-layout.e2e.ts):双面板打开 + 宽度拖拽 + rAF 逐帧采样,松手后断言——底边栏右缘与中心列右缘每帧偏差 ≤ 8px、无全宽帧、中心列右缘无过渡动画。
  • 判别性检查:未修复代码上该用例失败(实测失败帧 bottom 816 vs column 1440,正是根因);修复后通过。
  • 回归:typecheck ✅;vitest 639 passed | 5 skipped ✅;scripts/e2e-mount.sh 全部 8 条 e2e ✅。

@Menghuan1918
Menghuan1918 merged commit 5cc1a4b into main Aug 20, 2026
2 checks passed
@Menghuan1918
Menghuan1918 deleted the fix/bottom-panel-width-flash branch August 20, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant