Skip to content

Commit 7a186e7

Browse files
committed
limit right-click-to-peek to <summary>
1 parent a142ccb commit 7a186e7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/edit/editor-header.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function EditorHeader() {
1515
prefs.subscribe('editor.keyMap', showHotkeyInTooltip, true);
1616
window.on('showHotkeyInTooltip', showHotkeyInTooltip);
1717
}, {once: true});
18-
for (const el of $$('#header details')) {
18+
for (const el of $$('#header summary')) {
1919
el.on('contextmenu', peekDetails);
2020
}
2121
}
@@ -58,12 +58,13 @@ function initNameArea() {
5858

5959
async function peekDetails(evt) {
6060
evt.preventDefault();
61-
this.open = true;
62-
while (this.matches(':hover, :active')) {
61+
const elDetails = this.parentNode;
62+
if (!(elDetails.open = !elDetails.open)) return;
63+
while (elDetails.matches(':hover, :active')) {
6364
await sleep(500);
64-
await new Promise(cb => this.on('mouseleave', cb, {once: true}));
65+
await new Promise(cb => elDetails.on('mouseleave', cb, {once: true}));
6566
}
66-
this.open = false;
67+
elDetails.open = false;
6768
}
6869

6970
function showHotkeyInTooltip(_, mapName = prefs.get('editor.keyMap')) {

0 commit comments

Comments
 (0)