Skip to content

Commit

Permalink
limit right-click-to-peek to <summary>
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Dec 22, 2024
1 parent a142ccb commit 7a186e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/edit/editor-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function EditorHeader() {
prefs.subscribe('editor.keyMap', showHotkeyInTooltip, true);
window.on('showHotkeyInTooltip', showHotkeyInTooltip);
}, {once: true});
for (const el of $$('#header details')) {
for (const el of $$('#header summary')) {
el.on('contextmenu', peekDetails);
}
}
Expand Down Expand Up @@ -58,12 +58,13 @@ function initNameArea() {

async function peekDetails(evt) {
evt.preventDefault();
this.open = true;
while (this.matches(':hover, :active')) {
const elDetails = this.parentNode;
if (!(elDetails.open = !elDetails.open)) return;
while (elDetails.matches(':hover, :active')) {
await sleep(500);
await new Promise(cb => this.on('mouseleave', cb, {once: true}));
await new Promise(cb => elDetails.on('mouseleave', cb, {once: true}));
}
this.open = false;
elDetails.open = false;
}

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

0 comments on commit 7a186e7

Please sign in to comment.