diff --git a/components/calendar/task-modal.tsx b/components/calendar/task-modal.tsx
index 75ea6439a..0c2d5a45c 100644
--- a/components/calendar/task-modal.tsx
+++ b/components/calendar/task-modal.tsx
@@ -1,6 +1,7 @@
"use client";
import { useState, useEffect, useCallback, useRef, useMemo, useId } from "react";
+import { useCloseBesideControls } from "@/hooks/use-close-beside-controls";
import { useTranslations } from "next-intl";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -61,6 +62,9 @@ export function TaskModal({
}: TaskModalProps) {
const t = useTranslations("calendar");
const tCommon = useTranslations("common");
+ // The header's close goes to its start when the window's own close is at its end.
+ const [header, setHeader] = useState(null);
+ const closeFirst = useCloseBesideControls(header);
const id = useId();
const isEdit = !!task;
const titleRef = useRef(null);
@@ -212,6 +216,12 @@ export function TaskModal({
}
}, [requestClose, handleSave]);
+ const close = (
+
+
+
+ );
+
return (
// The desktop side panel is a dialog named by its title, like the event
// editor; on a phone the full-screen wrapper around it is.
@@ -222,13 +232,12 @@ export function TaskModal({
onKeyDown={handleKeyDown}
>
{/* Header */}
-
-
+
+ {closeFirst && close}
+
{isEdit ? t("tasks.edit") : t("tasks.create")}
-
-
-
+ {!closeFirst && close}
{/* Body */}
diff --git a/components/command-palette/__tests__/command-palette.test.tsx b/components/command-palette/__tests__/command-palette.test.tsx
index 2bd4fae1e..927e2b174 100644
--- a/components/command-palette/__tests__/command-palette.test.tsx
+++ b/components/command-palette/__tests__/command-palette.test.tsx
@@ -119,6 +119,41 @@ describe('command palette', () => {
expect(hint('search')).toBe('');
});
+ it('shows no single-key hints while single-key shortcuts are off, since those keys do nothing then', async () => {
+ const { useSettingsStore } = await import('@/stores/settings-store');
+ const hint = (label: string) => {
+ const row = screen.getAllByRole('option').find((o) => o.querySelector('.flex-1')?.textContent === label)!;
+ return [...row.querySelectorAll('kbd')].map((k) => k.textContent).join(' ');
+ };
+ useSettingsStore.setState({ singleKeyShortcuts: false });
+ try {
+ render();
+ pressCtrlK();
+ expect(hint('compose')).toBe('');
+ expect(hint('shortcuts')).toBe('');
+ } finally {
+ useSettingsStore.setState({ singleKeyShortcuts: true });
+ }
+ });
+
+ it('names the account Sign out leaves, as the account menu does', async () => {
+ const { useAccountStore } = await import('@/stores/account-store');
+ const before = useAccountStore.getState().accounts;
+ useAccountStore.setState({ accounts: [
+ { id: 'a1', email: 'one@example.org', username: 'one@example.org' },
+ { id: 'a2', email: 'two@example.org', username: 'two@example.org' },
+ ] } as never);
+ useAuthStore.setState({ activeAccountId: 'a2' } as never);
+ try {
+ render();
+ pressCtrlK();
+ expect(screen.getByText('sign_out_of(two@example.org)')).toBeInTheDocument();
+ expect(screen.queryByText('sign_out')).toBeNull();
+ } finally {
+ useAccountStore.setState({ accounts: before } as never);
+ }
+ });
+
it('shows plugin entries with the plugin name and runs them with Enter', async () => {
act(() => setPluginActions('jira', 'Jira', 'command-palette', [{ id: 'new-issue', label: 'Create issue' }]));
render();
diff --git a/components/command-palette/__tests__/mail-palette-commands.test.ts b/components/command-palette/__tests__/mail-palette-commands.test.ts
new file mode 100644
index 000000000..247954e94
--- /dev/null
+++ b/components/command-palette/__tests__/mail-palette-commands.test.ts
@@ -0,0 +1,28 @@
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+// Mail registers its palette commands in mail-app.tsx, which is too big to render
+// here. Each message action with a key in the shortcuts help is in the palette too,
+// under the key the help names.
+const source = readFileSync(path.join(process.cwd(), 'components/mail/mail-app.tsx'), 'utf8');
+const block = source.slice(source.indexOf("useRegisterCommands(t('sidebar.mail')"));
+
+describe('Mail commands in the palette', () => {
+ it.each([
+ ['reply', 'r'],
+ ['reply-all', 'a'],
+ ['forward', 'f'],
+ ['star', 's'],
+ ['archive', 'e'],
+ ['delete', '#'],
+ ['mark-unread', 'u'],
+ ['mark-read', 'Shift + I'],
+ ['spam', '!'],
+ ])('has %s, shown with %s', (id, key) => {
+ const at = block.indexOf(`id: '${id}'`);
+ expect(at).toBeGreaterThan(-1);
+ const entry = block.slice(at, block.indexOf('}', at));
+ expect(entry).toContain(`shortcut: '${key}'`);
+ });
+});
diff --git a/components/command-palette/command-palette.tsx b/components/command-palette/command-palette.tsx
index 058d4a448..8169769bd 100644
--- a/components/command-palette/command-palette.tsx
+++ b/components/command-palette/command-palette.tsx
@@ -27,6 +27,7 @@ import { useGlobalSearchStore } from "@/stores/global-search-store";
import { useCalendarStore } from "@/stores/calendar-store";
import { usePolicyStore } from "@/stores/policy-store";
import { useThemeStore } from "@/stores/theme-store";
+import { useSettingsStore } from "@/stores/settings-store";
import { usePluginActions } from "@/components/plugins/plugin-actions";
import { usePluginPages, pluginPageHref } from "@/hooks/use-plugin-pages";
import { KeyboardShortcutsModal } from "@/components/keyboard-shortcuts-modal";
@@ -38,7 +39,7 @@ import { commandMatches, useRegisteredCommandGroups } from "@/lib/command-regist
import { shortcutAlternatives } from "@/lib/shortcut-keys";
import { toUnicodeEmail } from "@/lib/idn";
import { isEditableEventTarget, isKeyboardLayerOpen } from "@/lib/keyboard";
-import { isSingleKeyShortcutOff } from "@/lib/single-key-shortcuts";
+import { isSingleKeyHint, isSingleKeyShortcutOff } from "@/lib/single-key-shortcuts";
import { useFocusTrap } from "@/hooks/use-focus-trap";
import { useMediaQuery } from "@/hooks/use-media-query";
import { IconButton } from "@/components/ui/icon-button";
@@ -162,6 +163,9 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
const activeAccountId = useAuthStore((s) => s.activeAccountId);
// A touch screen has no keyboard to use the shortcuts with (R8).
const touch = useMediaQuery("(pointer: coarse)");
+ // With single-key shortcuts off, "r" or "#" does nothing: no hint for it.
+ const singleKeys = useSettingsStore((s) => s.singleKeyShortcuts !== false);
+ const hintKeys = (shortcut: string) => shortcutAlternatives(shortcut).filter((key) => singleKeys || !isSingleKeyHint(key));
const inputRef = useRef(null);
const dialogRef = useFocusTrap({ isActive: true, onEscape: onClose, restoreFocus: true, initialFocus: () => inputRef.current });
@@ -255,7 +259,16 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
run: () => { void useAuthStore.getState().switchAccount(entry.id); },
});
}
- list.push({ id: "sign-out", group: account, icon: LogOut, label: tSidebar("sign_out"), run: () => { void useAuthStore.getState().logout(); } });
+ // It signs out of the open account only, as the account menu's entry says.
+ const current = accounts.find((entry) => entry.id === activeAccountId);
+ const currentName = current ? toUnicodeEmail(current.email || current.username) : "";
+ list.push({
+ id: "sign-out",
+ group: account,
+ icon: LogOut,
+ label: currentName ? tSidebar("sign_out_of", { account: currentName }) : tSidebar("sign_out"),
+ run: () => { void useAuthStore.getState().logout(); },
+ });
for (const action of pluginActions) {
list.push({
id: `plugin:${action.pluginId}:${action.id}`,
@@ -394,10 +407,10 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
{command.source && (
{command.source}
)}
- {command.shortcut && (
+ {command.shortcut && hintKeys(command.shortcut).length > 0 && (
// Key hints only where there is a keyboard (R8).
- {shortcutAlternatives(command.shortcut).map((key) => (
+ {hintKeys(command.shortcut).map((key) => (
{key}
))}
diff --git a/components/contacts/__tests__/contacts-app.test.tsx b/components/contacts/__tests__/contacts-app.test.tsx
index cd153f9e8..802c8f994 100644
--- a/components/contacts/__tests__/contacts-app.test.tsx
+++ b/components/contacts/__tests__/contacts-app.test.tsx
@@ -182,7 +182,7 @@ describe('ContactsApp', () => {
it('starts a new group with the contact when "Add to group" finds no group to add to', () => {
renderContacts();
fireEvent.contextMenu(screen.getByText('Alice Smith'));
- fireEvent.click(screen.getByText('context_menu.add_to_group'));
+ fireEvent.click(screen.getByText('contacts_add_to_group'));
expect(screen.getByText('groups.members_label (1)')).toBeInTheDocument();
});
@@ -190,11 +190,27 @@ describe('ContactsApp', () => {
const team: ContactCard = { id: 'g-team', kind: 'group', addressBookIds: {}, name: { full: 'Team' }, members: {} };
renderContacts([alice, bob, team]);
fireEvent.contextMenu(screen.getByText('Bob Jones'));
- fireEvent.click(screen.getByText('context_menu.add_to_group'));
+ fireEvent.click(screen.getByText('contacts_add_to_group'));
fireEvent.click(screen.getByText('bulk.new_group'));
expect(screen.getByText('groups.members_label (1)')).toBeInTheDocument();
});
+ it('offers no Edit, Move or Delete for a contact in an address book shared read-only', () => {
+ const shared = { ...alice, addressBookIds: { 'ab-shared': true } };
+ renderContacts([shared, bob]);
+ act(() => {
+ useContactStore.setState({ addressBooks: [{ id: 'ab-shared', name: 'Team', myRights: { mayRead: true, mayWrite: false } }] as never });
+ });
+ fireEvent.contextMenu(screen.getByText('Alice Smith'));
+ expect(screen.queryByRole('menuitem', { name: 'context_menu.edit' })).toBeNull();
+ expect(screen.queryByRole('menuitem', { name: /context_menu.delete/ })).toBeNull();
+ expect(screen.getByRole('menuitem', { name: 'context_menu.export_vcard' })).toBeInTheDocument();
+ fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' });
+
+ fireEvent.contextMenu(screen.getByText('Bob Jones'));
+ expect(screen.getByRole('menuitem', { name: 'context_menu.edit' })).toBeInTheDocument();
+ });
+
it('imports in a real dialog that Escape closes', () => {
renderContacts();
fireEvent.click(screen.getAllByRole('button', { name: 'open_categories' })[0]);
diff --git a/components/contacts/contact-context-menu.tsx b/components/contacts/contact-context-menu.tsx
index 9b6eea288..6281846ca 100644
--- a/components/contacts/contact-context-menu.tsx
+++ b/components/contacts/contact-context-menu.tsx
@@ -65,6 +65,8 @@ interface ContactContextMenuProps {
onBatchExport?: () => void;
onBatchAddToGroup?: () => void;
onBatchDelete?: () => void;
+ /** The contact is in an address book shared read-only: no Edit, Move or Delete. */
+ readOnly?: boolean;
}
export function ContactContextMenu({
@@ -88,8 +90,10 @@ export function ContactContextMenu({
onBatchExport,
onBatchAddToGroup,
onBatchDelete,
+ readOnly = false,
}: ContactContextMenuProps) {
const t = useTranslations("contacts");
+ const tMenu = useTranslations("menuAudit");
const printOff = useStrictestDevices().noPrint;
const email = getContactPrimaryEmail(contact);
const phone = getContactPrimaryPhone(contact);
@@ -134,7 +138,7 @@ export function ContactContextMenu({
onBatchAddToGroup?.())}
disabled={!onBatchAddToGroup}
/>
@@ -179,12 +183,12 @@ export function ContactContextMenu({
onClick={handle(handleCall)}
/>
)}
- {onEdit && }
+ {onEdit && !readOnly && }
{!inDetail && }
{onAddToGroup && (
)}
@@ -195,7 +199,7 @@ export function ContactContextMenu({
onClick={handle(onDuplicate)}
/>
)}
- {onMoveTo && (
+ {onMoveTo && !readOnly && (
)}
{email && (
@@ -225,13 +229,18 @@ export function ContactContextMenu({
onClick={handle(handlePrint)}
/>
)}
-
-
+ {!readOnly && (
+ <>
+
+
+ >
+ )}
);
}
diff --git a/components/contacts/contact-detail.tsx b/components/contacts/contact-detail.tsx
index 77edb2cdc..66a3969e2 100644
--- a/components/contacts/contact-detail.tsx
+++ b/components/contacts/contact-detail.tsx
@@ -35,6 +35,8 @@ interface ContactDetailProps {
onPrint?: () => void;
isMobile?: boolean;
className?: string;
+ /** In an address book shared read-only: no Edit, Move or Delete. */
+ readOnly?: boolean;
}
// Contexts and phone features the contact form offers, shown with the same
@@ -74,7 +76,7 @@ function getCompletedYears(dateInput: AnniversaryDate): number | null {
}
-export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDuplicate, onMoveTo, onCompose, onPrint, isMobile, className }: ContactDetailProps) {
+export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDuplicate, onMoveTo, onCompose, onPrint, isMobile, className, readOnly = false }: ContactDetailProps) {
const t = useTranslations("contacts");
const tCommon = useTranslations("common");
const locale = useLocale();
@@ -173,7 +175,7 @@ export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDupli
)}
{/* A phone's row has no room for this label: the ⋮ fell onto a line of its own. */}
- {isMobile ? (
+ {readOnly ? null : isMobile ? (
@@ -207,6 +209,7 @@ export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDupli
onClose={moreMenu.closeContextMenu}
menuRef={moreMenu.menuRef}
inDetail
+ readOnly={readOnly}
onCompose={onCompose}
onDelete={onDelete}
onAddToGroup={onAddToGroup}
diff --git a/components/contacts/contact-form.tsx b/components/contacts/contact-form.tsx
index 2191820e5..fac3205b0 100644
--- a/components/contacts/contact-form.tsx
+++ b/components/contacts/contact-form.tsx
@@ -1,6 +1,7 @@
"use client";
import { useState, useMemo, useCallback, useRef, useEffect, useId } from "react";
+import { useCloseBesideControls } from "@/hooks/use-close-beside-controls";
import { useTranslations } from "next-intl";
import { X, Plus, ChevronDown, ChevronRight, User, Building, MapPin, Globe, Cake, Heart, Tag, StickyNote, Mail, Phone, Calendar, UserCircle, Book, Camera, Trash2 } from "@/components/icons";
import { Button } from "@/components/ui/button";
@@ -220,6 +221,9 @@ function Select({ value, onChange, children, className, id, "aria-label": ariaLa
export function ContactForm({ contact, addressBooks, allKeywords, defaultAddressBookId, prefill, onSave, onCancel, loadCurrentMedia, onDirtyChange }: ContactFormProps) {
const t = useTranslations("contacts.form");
const isEditing = !!contact;
+ // The header's close goes to its start when the window's own close is at its end.
+ const [header, setHeader] = useState(null);
+ const closeFirst = useCloseBesideControls(header);
// Ids that tie each visible label to its field.
const fieldIdBase = useId();
const fieldId = (key: string) => `${fieldIdBase}-${key}`;
@@ -700,17 +704,22 @@ export function ContactForm({ contact, addressBooks, allKeywords, defaultAddress
const previewName = (isOrg ? "" : [givenName, surname].filter(Boolean).join(" ").trim()) || organization.trim();
const previewEmail = emails.find(e => e.address.trim())?.address.trim() || "";
+ const close = (
+
+
+
+ );
+
return (
// The app checks the fields itself and says what is wrong inline; the
// browser's own bubble covered that message.