Esc does not exit multi-cursor mode due to hidden comment toolbar intercepting keydown
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 22/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript
- 領域
- frontend
研究方向
This repository is the issue tracker, so the code is not here; the report points at the bundled asset es2015-B-MiIaIH.js and Radix UI's DismissableLayer. Start by reproducing the Escape behaviour in the editor and checking whether a hidden comment toolbar stays in the layer stack. Done means Escape collapses multiple CodeMirror selections while that toolbar is hidden, and the report is moved to or linked from the right repository.
由索引模型根據 Issue 內容生成。
描述
- Yes, the bug happens on https://hackmd.io/
- No. If it's a self-hosted CodiMD instance, please file the issue in the CodiMD repository.
What's the problem
Current behaviour
Pressing Esc does not exit multi-cursor mode in the HackMD editor.
This appears to be caused by a hidden comment floating toolbar intercepting the Escape key through Radix UI's DismissableLayer before CodeMirror can process it.
Steps to reproduce:
- Open a note on https://hackmd.io/ in edit mode.
- Press
Ctrl + Shift + Up/Downto create multiple cursors. - Press
Esc. - Observe that the multiple cursors remain active.
The issue also reproduces in Chrome Incognito mode.
Expected behaviour
Pressing Esc should remove the additional cursors, leaving a single cursor, as defined by CodeMirror's Sublime keymap.
Environment
Desktop:
- OS: macOS
- Browser: Google Chrome
- Browser Version: 156
Mobile:
- Not tested
Additional context
I investigated this issue using Chrome DevTools and identified what appears to be the root cause.
- CodeMirror 5 uses the
sublimekeymap, whereEscis mapped tosingleSelectionTop. - Calling
cm.execCommand("singleSelectionTop")directly works correctly. - The Escape
keydownevent reaches CodeMirror, butdefaultPreventedis alreadytrue. - A document-level capture listener calls
preventDefault()before CodeMirror handles the event. - The caller appears to be Radix UI's
DismissableLayerin HackMD'ses2015-B-MiIaIH.jsasset.
Inspecting the handler's closure showed that the associated element is a comment floating toolbar:
element.innerText:"コメント"(Comment)element.isConnected:truegetComputedStyle(element).display:"none"element.classNameincludeshidden- The element remains registered in
dismissableLayers.layers. - The handler considers itself the topmost layer.
Despite being hidden, the comment toolbar's DismissableLayer still consumes Escape events.
The event trace confirms:
windowcapture:defaultPrevented = falsedocumentcapture:defaultPrevented = true- CodeMirror keydown:
defaultPrevented = true - CodeMirror
keyHandled: not emitted - Selection count remains unchanged
Confirmed workaround
Registering a keydown listener on window in the capture phase and calling cm.execCommand("singleSelectionTop") when multiple selections exist restores the expected behaviour.
Suggested fix
Please investigate the lifecycle and Escape handling of the comment floating toolbar's DismissableLayer.
The hidden toolbar should not consume Escape key events intended for CodeMirror. Unmounting or disabling the DismissableLayer while the toolbar is hidden may resolve the issue.
I can provide DevTools screenshots and additional debugging information if needed.
- 主要語言
- 沒有語言資料
- 星號
- 40
- 分支
- 9
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
hackmdio/hackmd-io-issues 的其他 Issue
-
bug
難度 1/5 1-3 小時 新手友好度 62/100
hackmdio/hackmd-io-issues#121 ·
-
難度 4/5 3-5 天 新手友好度 25/100
hackmdio/hackmd-io-issues#448 ·
-
難度 4/5 3-5 天 新手友好度 15/100
hackmdio/hackmd-io-issues#447 ·
-
難度 4/5 3-5 天 新手友好度 45/100
hackmdio/hackmd-io-issues#446 ·
-
難度 2/5 1-3 小時 新手友好度 30/100
hackmdio/hackmd-io-issues#444 · 1 則留言 ·
查看 hackmdio/hackmd-io-issues 的全部 Issue
相似的 Issue
-
marketing
難度 2/5 1-3 小時 新手友好度 94/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
yavorsky/unbuilt.app#65 ·
-
android needs clarification
難度 2/5 1-3 小時 新手友好度 72/100
super-productivity/super-productivity#12105 · 3 則留言 ·
維護者通常 1 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 78/100
NotAFlightRisk/statusquo#52 ·
維護者通常 1 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 85/100
shuxiachai/academic-commercialization-agent#531 ·
維護者通常 1 天內回覆