shell: Ctrl+F, F3 and the Find row reach the last web tab when the app's own tab is in front

On macOS the shell can hold the keyboard while its own settings tab is active; Ctrl+F then did
nothing, so typed keys and Enter went to X's search field. Find now targets the last web tab that
was in front (or the first one on screen).
This commit is contained in:
CRTkafa 2026-10-01 05:31:08 +07:00
parent 2bfd00e875
commit d84220d465
2 changed files with 16 additions and 3 deletions

View file

@ -306,7 +306,7 @@ export function AppMenu({ trigger = true }: { trigger?: boolean } = {}) {
case 'store': return item(id, section(t('wb.panel.section.store')), 'bag', { run: () => shell.openPanelSection('store') }); case 'store': return item(id, section(t('wb.panel.section.store')), 'bag', { run: () => shell.openPanelSection('store') });
case 'strings': return item(id, section(menuText('strings')), 'globe', { run: () => shell.openPanelSection('languages') }); case 'strings': return item(id, section(menuText('strings')), 'globe', { run: () => shell.openPanelSection('languages') });
case 'workspaces': return item(id, t('wb.ws.title'), 'layout', { submenu: true, hint: workspaces.store.items.find(entry => entry.id === workspaces.active)?.name }); case 'workspaces': return item(id, t('wb.ws.title'), 'layout', { submenu: true, hint: workspaces.store.items.find(entry => entry.id === workspaces.active)?.name });
case 'find': return item(id, menuText('find'), 'search', { shortcut: 'Ctrl+F', disabled: !active || !isWeb(active), run: () => shell.shortcut('find') }); case 'find': return item(id, menuText('find'), 'search', { shortcut: 'Ctrl+F', disabled: !(shell.api?.panels ?? []).some(panel => isWeb(panel) && panel.api.isVisible), run: () => shell.shortcut('find') });
case 'shortcuts': return item(id, menuText('shortcuts'), 'keyboard', { run: () => (menu.shortcuts ? menu.shortcuts() : shell.shortcut('command-palette')) }); case 'shortcuts': return item(id, menuText('shortcuts'), 'keyboard', { run: () => (menu.shortcuts ? menu.shortcuts() : shell.shortcut('command-palette')) });
case 'palette': return item(id, menuText('palette'), 'command', { shortcut: 'Ctrl+K', run: () => shell.shortcut('command-palette') }); case 'palette': return item(id, menuText('palette'), 'command', { shortcut: 'Ctrl+K', run: () => shell.shortcut('command-palette') });
case 'developer': return item(id, menuText('developer'), 'code', { submenu: true }); case 'developer': return item(id, menuText('developer'), 'code', { submenu: true });

View file

@ -149,6 +149,18 @@ function openAccount(profile: string, options: { force?: boolean; url?: string }
const deckPanelId = (deckId: string) => `deck-${deckId}`; const deckPanelId = (deckId: string) => `deck-${deckId}`;
/** The last focused tab that is not a deck, for Ctrl+Shift+D back and forth. */ /** The last focused tab that is not a deck, for Ctrl+Shift+D back and forth. */
let lastNonDeck: string | null = null; let lastNonDeck: string | null = null;
/** The last web tab that was in front (Ctrl+F from the app's own tab searches it). */
let lastWeb: string | null = null;
/**
* The web tab Ctrl+F searches: the one given, else the last web tab that was in front and is still
* on screen, else the first web tab on screen. The app's own tab has no page to search.
*/
function findTarget(panel: IDockviewPanel | undefined): IDockviewPanel | undefined {
if (panel && isWeb(panel)) return panel;
const shown = (shell.api?.panels ?? []).filter(item => isWeb(item) && item.api.isVisible);
return shown.find(item => item.id === lastWeb) ?? shown[0];
}
/** Opens (or focuses) a deck tab; with no deck yet, creates one. */ /** Opens (or focuses) a deck tab; with no deck yet, creates one. */
function openDeck(deckId?: string) { function openDeck(deckId?: string) {
@ -308,8 +320,8 @@ function runShortcut(shortcut: string, id?: string) {
switch (shortcut) { switch (shortcut) {
case 'new-tab': addStart(); break; case 'new-tab': addStart(); break;
// Find in page: the find bar of that tab (the one the keys were pressed in, else the one in front). // Find in page: the find bar of that tab (the one the keys were pressed in, else the one in front).
case 'find': if (panel && isWeb(panel) && hasFeature('find')) { panel.api.setActive(); openFind(panel.id); } break; case 'find': { const target = findTarget(panel); if (target && hasFeature('find')) { target.api.setActive(); openFind(target.id); } break; }
case 'find-next': case 'find-previous': if (panel && isWeb(panel)) stepFind(panel.id, shortcut === 'find-next' ? 1 : -1); break; case 'find-next': case 'find-previous': { const target = findTarget(panel); if (target) stepFind(target.id, shortcut === 'find-next' ? 1 : -1); break; }
case 'close-tab': if (panel) closeTab(panel); break; case 'close-tab': if (panel) closeTab(panel); break;
case 'reopen-tab': { const tab = shell.closed.pop(); if (tab) addWeb(tab.url, undefined, true, tab.profile); break; } case 'reopen-tab': { const tab = shell.closed.pop(); if (tab) addWeb(tab.url, undefined, true, tab.profile); break; }
case 'focus-address': if (panel && (isWeb(panel) || (panel.params as TabParams).kind === 'start')) focusAddress(panel.id); break; case 'focus-address': if (panel && (isWeb(panel) || (panel.params as TabParams).kind === 'start')) focusAddress(panel.id); break;
@ -822,6 +834,7 @@ export default function Shell() {
const paneChanged = () => window.dispatchEvent(new CustomEvent('bt-active-pane')); const paneChanged = () => window.dispatchEvent(new CustomEvent('bt-active-pane'));
api.onDidActivePanelChange(event => { api.onDidActivePanelChange(event => {
if (event && (event.params as TabParams | undefined)?.kind !== 'deck') lastNonDeck = event.id; if (event && (event.params as TabParams | undefined)?.kind !== 'deck') lastNonDeck = event.id;
if (event && isWeb(event)) lastWeb = event.id;
notePanelActive(event?.id); notePanelActive(event?.id);
scheduleSync(); scheduleSync();
paneChanged(); paneChanged();