detached d5a4bab

omnibox: close overlay when clicking outside the box (capture phase); stop propagation from box to avoid accidental closes

commit
d5a4bab0b78cd862d87467fd92c013ac3bf7ac09
author
bamen · · 2025-09-09 19:00 UTC
committer
bamen · · 2025-09-09 16:57 UTC
parent
9de5dca
signature
unsigned
1 file · +10 -0
M pkg/webkit/ucm_js_cgo.go +10 -0
@@ -92,6 +92,16 @@ func getOmniboxScript() string {
9292 document.documentElement.appendChild(style);
9393 box.appendChild(input); box.appendChild(list); root.appendChild(box); document.documentElement.appendChild(root);
9494 H.box = box;
95+ // Click outside the box closes the overlay
96+ root.addEventListener('mousedown', (e)=>{
97+ const tgt = e.target;
98+ if (tgt && box && !box.contains(tgt)) {
99+ e.preventDefault();
100+ e.stopPropagation();
101+ H.close();
102+ }
103+ }, true);
104+ box.addEventListener('mousedown', (e)=>{ e.stopPropagation(); }, true);
95105 // Focus and select input on hover for quick typing
96106 input.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); input.select(); } catch(_) { input.focus(); } } });
97107 root.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); } catch(_) { input.focus(); } } });
@@ -92,6 +92,16 @@ func getOmniboxScript() string {
92 document.documentElement.appendChild(style);92 document.documentElement.appendChild(style);
93 box.appendChild(input); box.appendChild(list); root.appendChild(box); document.documentElement.appendChild(root);93 box.appendChild(input); box.appendChild(list); root.appendChild(box); document.documentElement.appendChild(root);
94 H.box = box;94 H.box = box;
95+ // Click outside the box closes the overlay
96+ root.addEventListener('mousedown', (e)=>{
97+ const tgt = e.target;
98+ if (tgt && box && !box.contains(tgt)) {
99+ e.preventDefault();
100+ e.stopPropagation();
101+ H.close();
102+ }
103+ }, true);
104+ box.addEventListener('mousedown', (e)=>{ e.stopPropagation(); }, true);
95 // Focus and select input on hover for quick typing105 // Focus and select input on hover for quick typing
96 input.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); input.select(); } catch(_) { input.focus(); } } });106 input.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); input.select(); } catch(_) { input.focus(); } } });
97 root.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); } catch(_) { input.focus(); } } });107 root.addEventListener('mouseenter', ()=>{ if (H.visible) { try { input.focus({preventScroll:true}); } catch(_) { input.focus(); } } });

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close