Skip to content

fix(sheet): centre the sheet on the window only when the frame has the room - #91

Merged
Yundi339 merged 1 commit into
mainfrom
fix/centre-sheet-fit
Nov 27, 2026
Merged

Yundi339 merged 1 commit into
mainfrom
fix/centre-sheet-fit

Conversation

@Yundi339

Copy link
Copy Markdown
Member

说明

#90 让窄 frame 的居中弹窗变成横跨 frame 的底部弹层,弹层仍贴着 frame 底边,不是居中形态。设置页的 frame 只是列表右侧的详情区时,窗口中心还会落在 frame 边缘之外:偏移使宽度公式的第三项为负,width 退回 auto,弹窗塌缩成逐字换行的细条(“强制指定捕获方法”选择器)。

修改

  • useModalBridge 收到 frame 偏移时判断 frame 是否容得下按窗口居中的弹窗(centresOnWindow),并标记 data-m-frame="fit" | "frame"。
  • fit:保持按 GUI 窗口居中,宽度按可用空间收窄。
  • frame:弹窗在内容 frame 内居中、使用完整设计宽度 min(600px, 100vw - 32px),不再依赖偏移量,不会塌缩。
  • 窄窗口的底部弹层只保留给独立窗口的 WebUI。
  • 测试覆盖两种放置与判定(含 444px 详情区、-228px 偏移的几何)。

…e room

A frame that is the detail pane beside the list puts the window middle near its edge; the width term went negative and the width fell back to auto, a sliver. The sheet now stands in the middle of the frame at its full width when the window-centred placement cannot hold it, and the under-600 bottom sheet stays for standalone windows.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • 优化弹窗在窄屏和嵌入式窗口中的显示位置:根据可用空间选择以窗口或嵌入框架为中心;窄屏下,嵌入式弹窗保持居中对话框布局。

桥接逻辑根据框架宽度和水平偏移判断弹窗是否可在窗口居中,并设置 data-m-frame 标记。CSS 根据标记应用居中弹窗样式。测试覆盖判定结果及框架内和独立窗口的样式。

Changes: 弹窗居中布局

Layer / File(s) Summary
框架居中判定与标记
src/vue/useModalBridge.js, test/centersheet.test.js
新增 centresOnWindow(frameWidth, dx),并在处理 MODAL_FRAME 消息时,根据判定结果将 data-m-frame 设为 fit 或 frame。测试覆盖多组宽度和偏移值。
标记对应的弹窗样式
src/css/expressive.css, test/centersheet.test.js
frame 标记使用常规对话框宽度且不应用窗口偏移。窄屏底部弹出规则仅适用于未设置 data-m-frame 的文档。测试检查框架内和独立窗口的样式。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • AlkaidLab/foundation-ui#89:该 PR 调整 MODAL_FRAME 偏移量的重新测量和发送时机,与本次改动使用的偏移量相关。

Suggested reviewers: skyhua0224

Merge Risk: Minimal · up to 2e16b

This change fixes sheet placement when the content frame is narrow or offset, so the sheet no longer collapses into a narrow strip. No concrete merge-blocking risk was found. The change is small and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(sheet): centre the sheet on the window only when the frame has the room”描述了主要变更:仅当 frame 空间足够时才将弹窗居中于窗口。这与 raw_summary 中的 centresOnWindow 判定、data-m-frame 标记以及 PR 目标一致。标题使用英文,且略长(75 个字符),但与变更内容相…
Description check Passed 描述说明了问题(窄 frame 的居中弹窗塌缩为细条)、修改内容(useModalBridge 中的 centresOnWindow 判定、data-m-frame 的 fit/frame 标记、窄窗口底部弹层仅保留给独立窗口)以及测试覆盖。与变更集直接相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“fix(sheet): centre the sheet on the window only when the frame has the room”描述了主要变更:仅当 frame 空间足够时才将弹窗居中于窗口。这与 raw_summary 中的 centresOnWindow 判定、data-m-frame 标记以及 PR 目标一致。标题使用英文,且略长(75 个字符),但与变更内容相关。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

兔子看见弹窗居中,
框架宽窄都算清。
偏移传来分 fit、frame,
窄屏布局各有形。
测试点头,胡萝卜香。

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 308055d1-a010-4af1-a1ed-5b1f35ebe53b
Commits

Reviewing files that changed from the base of the PR and between c6dd4b3 and 2e16b75.

Files selected for processing: 3

  • src/css/expressive.css
  • src/vue/useModalBridge.js
  • test/centersheet.test.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Yundi339
Yundi339 merged commit 45865fe into main Nov 27, 2026
7 checks passed
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