Esc does not exit multi-cursor mode due to hidden comment toolbar intercepting keydown
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 22/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript
- Bereich
- frontend
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
- 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.
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 40
- Forks
- 9
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus hackmdio/hackmd-io-issues
-
bug
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 62/100
hackmdio/hackmd-io-issues#121 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
hackmdio/hackmd-io-issues#448 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 15/100
hackmdio/hackmd-io-issues#447 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
hackmdio/hackmd-io-issues#446 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 30/100
hackmdio/hackmd-io-issues#444 · 1 Kommentar ·
Alle Issues in hackmdio/hackmd-io-issues
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
EmulatorJS/EmulatorJS#1317 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
area:server area:tests
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
signalapp/Signal-Android#15150 ·
Maintainer antworten meist innerhalb von 1 Tag