fix(layout): 拖拽松手后底边栏不再闪全宽 (#258) - #259
Merged
Merged
Conversation
This was referenced Aug 20, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
每次拖动右侧栏(宽度)松手后,底边栏先瞬间变成全宽(盖过右侧栏),然后约 300ms 动画滑回新的正确宽度。#258。
根因
松手时 store 提交宽度 → 布局推挤 effect(
--dsh-sidebar-width/height写入)依赖变化 → 其 cleanup 会 removeProperty 推挤变量。React 被动 effect flush 的 cleanup 与 setup 之间会让出渲染帧(逐帧采样证实):浏览器先绘制出「推挤已释放」的布局(#rootmargin 0、中心列全宽,且data-dsh-sidebar-dragging已移除、margin 过渡重新启用),随后 setup 重写变量 →#rootmargin-right 从 0 过渡动画回新宽度;同一间隙中拖拽结束的 measureCenter 缓存了全宽的中心列 rect → 底边栏被渲染成全宽,再被 ResizeObserver 逐帧跟随动画修正。修复
推挤变量的清理拆成 unmount-only effect:挂载期间变量持续有效,不存在可被绘制/测量到的推挤释放窗口;卸载(RenderBoundary 崩溃替换 / HMR fiber 释放)时仍释放推挤,保持 issue #31 的保证。
测试
drag-layout.e2e.ts):双面板打开 + 宽度拖拽 + rAF 逐帧采样,松手后断言——底边栏右缘与中心列右缘每帧偏差 ≤ 8px、无全宽帧、中心列右缘无过渡动画。bottom 816 vs column 1440,正是根因);修复后通过。scripts/e2e-mount.sh全部 8 条 e2e ✅。