fix(mobile): a tap that closes a pane's menu does only that

Closing the ⋯ menu by tapping the pane also brought the keyboard up for
typing into it. The tap that puts a menu away is the menu's now.
This commit is contained in:
l0ng-ai
2026-10-03 20:27:44 +08:00
parent 23a91ae674
commit cf9dfb2abb
+9 -1
View File
@@ -2151,11 +2151,17 @@ interface MenuItem {
/** A trailing ⋯ button with a small menu that drops from it. Items can be
* given as a function, to be read afresh each time it opens. */
/** When a menu was last put away by a press outside it: that press is the
* menu's, not whatever lies under it. */
let menuDismissedAt = 0;
function menuButton(items: MenuItem[] | (() => MenuItem[]), cls = "nav-icon") {
const wrap = h("div", { class: "menu-wrap" });
const list = h("div", { class: "menu", role: "menu", hidden: true });
const outside = (e: Event) => {
if (!wrap.contains(e.target as Node)) close();
if (wrap.contains(e.target as Node)) return;
menuDismissedAt = performance.now();
close();
};
const close = () => {
list.hidden = true;
@@ -3216,6 +3222,8 @@ function terminalScreen(host: Host, place: Place, pane: PaneView, title: string,
// focus to its own textarea.
if (lifted && !lifted.axis && e.cancelable) {
e.preventDefault();
// A tap that closed an open menu does only that.
if (performance.now() - menuDismissedAt < 500) return;
// A link under the finger opens in the browser instead.
const at = e.changedTouches[0];
const url = at && linkAt(at.clientX, at.clientY);