Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(ui): fix settings tabs being in wrong location on desktop. (#2807)

Fake-User4fa251780c2a
diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsx
index 4b4ba367a0..4a1ec8880a 100644
--- a/js/app/packages/app/component/settings/Settings.tsx
+++ b/js/app/packages/app/component/settings/Settings.tsx
@@ -1,6 +1,7 @@
import { createEffect, onMount, Show, Suspense } from 'solid-js';
import { type SettingsTab, useSettingsState } from '@core/constant/SettingsState';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import { isMobile } from '@core/mobile/isMobile';
import { usePermissions } from '@core/context/user';
import { DEV_MODE_ENV, ENABLE_APP_STORE_QR_CODE } from '@core/constant/featureFlags';
import { Subscription } from './Subscription';
@@ -40,16 +41,18 @@ export function SettingsPanel(props: SettingsPanelProps) {
const [attachHotkeys, settingsHotkeyScope] = useHotkeyDOMScope('settings');
let settingsContainerRef: HTMLDivElement | undefined;
- createEffect(() => {
+ function focusSettingsOnOpen() {
if (settingsOpen()){
setTimeout(() => {
// Focus the settings container to activate the hotkey scope
settingsContainerRef?.focus();
}, 10);
}
- });
+ }
- const settingsTabs = () => {
+ createEffect(focusSettingsOnOpen);
+
+ function settingsTabs() {
const tabs: { value: string; label: string }[] = [
{ value: 'Appearance', label: 'Appearance' },
{ value: 'Account', label: 'Account' },
@@ -60,7 +63,7 @@ export function SettingsPanel(props: SettingsPanelProps) {
if (ENABLE_APP_STORE_QR_CODE && !isNativeMobilePlatform()) { tabs.push({ value: 'Mobile App', label: 'App' }) }
if (isNativeMobilePlatform() && DEV_MODE_ENV) { tabs.push({ value: 'Mobile', label: 'Mobile Dev Tools' }) }
return tabs;
- };
+ }
// Attach hotkeys to the settings container
onMount(() => {
@@ -69,19 +72,21 @@ export function SettingsPanel(props: SettingsPanelProps) {
}
});
+ function handleEscapeKey() {
+ closeSettings();
+ return true;
+ }
+
// Register Escape key to close settings
registerHotkey({
- hotkey: 'escape',
- scopeId: settingsHotkeyScope,
+ keyDownHandler: handleEscapeKey,
description: 'Close settings',
- keyDownHandler: () => {
- closeSettings();
- return true;
- },
+ scopeId: settingsHotkeyScope,
+ hotkey: 'escape',
});
// Helper to navigate to a tab by index
- const navigateToTabIndex = (index: number): boolean => {
+ function navigateToTabIndex(index: number): boolean {
const tabs = settingsTabs();
if (index >= 0 && index < tabs.length) {
const tab = tabs[index];
@@ -91,60 +96,66 @@ export function SettingsPanel(props: SettingsPanelProps) {
}
}
return false;
- };
+ }
- const getCurrentTabIndex = () => {
+ function getCurrentTabIndex() {
const tabs = settingsTabs();
return tabs.findIndex(tab => tab.value === activeTabId());
- };
+ }
+
+ function handleNextTab() {
+ const tabs = settingsTabs();
+ const nextIndex = getCurrentTabIndex() >= tabs.length - 1 ? 0 : getCurrentTabIndex() + 1;
+ navigateToTabIndex(nextIndex);
+ return true;
+ }
+
+ function handlePreviousTab() {
+ const tabs = settingsTabs();
+ const nextIndex = getCurrentTabIndex() <= 0 ? tabs.length - 1 : getCurrentTabIndex() - 1;
+ navigateToTabIndex(nextIndex);
+ return true;
+ }
// Register Tab key for next tab navigation
registerHotkey({
hotkey: 'tab',
scopeId: settingsHotkeyScope,
description: 'Next settings tab',
- keyDownHandler: () => {
- const tabs = settingsTabs();
- const nextIndex = getCurrentTabIndex() >= tabs.length - 1 ? 0 : getCurrentTabIndex() + 1;
- navigateToTabIndex(nextIndex);
- return true;
- },
+ keyDownHandler: handleNextTab,
hide: true,
});
// Register Shift+Tab for previous tab navigation
registerHotkey({
- hotkey: 'shift+tab',
- scopeId: settingsHotkeyScope,
description: 'Previous settings tab',
- keyDownHandler: () => {
- const tabs = settingsTabs();
- const nextIndex = getCurrentTabIndex() <= 0 ? tabs.length - 1 : getCurrentTabIndex() - 1;
- navigateToTabIndex(nextIndex);
- return true;
- },
+ keyDownHandler: handlePreviousTab,
+ scopeId: settingsHotkeyScope,
+ hotkey: 'shift+tab',
hide: true,
});
// Register number keys 1-9 for direct tab navigation
for (let i = 1; i <= 9; i++) {
const keyNum = i;
+ function handleNumberKey() { return navigateToTabIndex(keyNum - 1); }
registerHotkey({
+ description: `Go to settings tab ${keyNum}`,
hotkey: `${keyNum}` as ValidHotkey,
+ keyDownHandler: handleNumberKey,
scopeId: settingsHotkeyScope,
- description: `Go to settings tab ${keyNum}`,
- keyDownHandler: () => navigateToTabIndex(keyNum - 1),
hide: true,
});
}
- const handleTabChange = (value: string) => {
+ function handleTabChange(value: string) {
if (value === 'Account' || value === 'Subscription' || value === 'Appearance' || value === 'Mobile' || value === 'AI Memory' || value === 'Shortcuts' || value === 'Mobile App') {
setActiveTabId(value as SettingsTab);
}
- };
+ }
- const BottomTabs = () => (
+ function BottomTabs() {
+ return (
<div class="bg-panel border-t border-edge-muted h-11 px-1">
<Tabs
list={settingsTabs()}
@@ -155,28 +166,34 @@ export function SettingsPanel(props: SettingsPanelProps) {
class="[&_[data-indicator]]:h-[3px]"
/>
</div>
- );
+ );
+ }
return (
<div
class="size-full flex flex-col outline-none bracket-never"
- classList={{
- invisible: props.hide,
- }}
+ classList={{ invisible: props.hide }}
tabIndex={0}
ref={settingsContainerRef}
>
- {/* Header */}
+
<SplitHeaderLeft>
<div class="h-full flex gap-3 items-center">
<h1 class="font-semibold text-ink select-none text-sm shrink-0">
Settings
</h1>
+ <Show when={!isMobile()}>
+ <Tabs
+ list={settingsTabs()}
+ value={activeTabId()}
+ defaultValue="Appearance"
+ onChange={handleTabChange}
+ />
+ </Show>
</div>
</SplitHeaderLeft>
- {/* Content area */}
- <div class="relative flex-grow min-h-1 overflow-auto">
+ <div class="relative grow min-h-1 overflow-auto">
<Show when={activeTabId() === 'Account'}>
<Suspense>
<Account />
@@ -195,8 +212,10 @@ export function SettingsPanel(props: SettingsPanelProps) {
<MobileApp />
</Show>
</div>
- {/* Bottom tabs */}
- <BottomTabs />
+
+ <Show when={isMobile()}>
+ <BottomTabs />
+ </Show>
</div>
);
}