fix: 批注工具条默认出现在选区下方(below-first),避开原生选中菜单遮挡 - #48
Open
Dawn388887 wants to merge 1 commit into
Open
Conversation
原生选中菜单(移动端长按菜单、桌面 Edge/Chrome Copy/Search 浮层)锚定在 选区上沿附近,且原生 UI 恒绘制在页面内容之上,工具条放在上方必被遮挡, z-index 无法补救。placeAbove() 改为下方优先:下方放得下(bottom + 8 后仍 留 8px 边距)即放下方,否则回落上方并保留原有底部钳制。rect 与 window.innerHeight 同为布局视口坐标系,Android 地址栏伸缩时判断依然一致。 双端实测:Windows 11 桌面 Edge + Android 平板(联想 Y700)Edge, DSH 0.1.2-rc.1 + @changfenhuang/dsh-annotation 1.4.8。
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.
问题
选中助手消息文字后,批注工具条默认出现在选区上方,移动端会被浏览器原生长按菜单(复制/搜索/分享浮层)直接盖住:原生菜单锚定在选区上沿附近,且原生 UI 恒绘制在页面内容之上,工具条无论 z-index 多大都无法显示在其上层。桌面端 Edge/Chrome 的原生 Copy/Search 浮层同理。
复现(移动端 100%):Android 平板(联想 Y700)+ Edge 打开 DSH Web,长按选中助手回复中任意文字 → 工具条出现在选区上方,与原生长按菜单重叠,无法点击。
根因
placeAbove()目前上方优先(top = rect.top - height - 8,上方放不下才回落下方),而原生选中菜单恰好也锚定选区上沿,两者必然重叠。方案
placeAbove()改为下方优先(below-first):belowTop = rect.bottom + 8;若belowTop + height <= window.innerHeight - 8则放下方坐标系一致性:
rect(getBoundingClientRect,布局视口坐标)与window.innerHeight(布局视口高)同属布局视口坐标系,Android 地址栏伸缩时两者同步变化,判断在任意状态下都一致(未引入 visualViewport)。测试
@changfenhuang/dsh-annotation1.4.8