feat(client): phone-edit row dilation + mobile contacts layout

InlinePhoneField now lays the country picker + number on top, with Save +
Cancel buttons on a second line — the previous single-line cluster was
cramped at every viewport size and broke entirely below ~480px.

A new onEditingChange callback notifies the parent when the field enters
edit mode, so contact rows can react. ContactsEditor uses it to "dilate"
the row visually: lift out of the muted baseline with a soft primary
ring + slightly brighter surface + bumped padding. Single visual signal
replaces the need for any "now editing" label, and the dilation also
hides the noisy chip cluster (label / star / trash) that would otherwise
fight the editor for space.

Mobile improvements applied at the same time:
  - Each row stacks value editor on top, action cluster below at <sm
  - Action cluster ("Add tag" + Make-primary star + trash) uses
    justify-end on the new row so it doesn't collide with the picker
  - Trash icon stays opacity-0/group-hover on desktop but is always
    visible on touch (no hover state on touch) — sm:opacity-0 +
    sm:group-hover:opacity-100 instead of the prior unconditional fade
  - NewContactForm wraps onto multiple lines below sm (basis-full on
    the value field) so the channel picker, value, label, and buttons
    each get usable width

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-05-03 16:15:07 +02:00
parent 596476280d
commit cf1c8b66db
2 changed files with 123 additions and 77 deletions

View File

@@ -17,6 +17,12 @@ interface InlinePhoneFieldProps {
/** Falls back to this country if `country` isn't set. */
defaultCountry?: CountryCode;
onSave: (next: { e164: string | null; country: CountryCode }) => Promise<void>;
/**
* Notifies the parent when the field enters/exits edit mode. Lets the row
* dim or hide noise (tag chips, action buttons) while the user is focused
* on the editor.
*/
onEditingChange?: (editing: boolean) => void;
emptyText?: string;
disabled?: boolean;
className?: string;
@@ -28,12 +34,13 @@ export function InlinePhoneField({
country,
defaultCountry,
onSave,
onEditingChange,
emptyText = '—',
disabled,
className,
'data-testid': testId,
}: InlinePhoneFieldProps) {
const [editing, setEditing] = useState(false);
const [editing, setEditingRaw] = useState(false);
const [draft, setDraft] = useState<PhoneInputValue | null>(() => {
if (!e164 && !country) return null;
return {
@@ -43,6 +50,11 @@ export function InlinePhoneField({
});
const [saving, setSaving] = useState(false);
function setEditing(next: boolean) {
setEditingRaw(next);
onEditingChange?.(next);
}
async function commit() {
const next = draft ?? { e164: null, country: defaultCountry ?? 'US' };
if (next.e164 === (e164 ?? null) && next.country === (country ?? null)) {
@@ -62,39 +74,50 @@ export function InlinePhoneField({
if (editing) {
return (
<div className={cn('flex items-center gap-1', className)}>
// Two clean lines: country picker + number on top, action pair below.
<div className={cn('flex w-full flex-col gap-2.5', className)}>
<PhoneInput
value={draft}
onChange={(v) => setDraft(v)}
defaultCountry={defaultCountry}
data-testid={testId}
/>
<button
type="button"
onClick={() => void commit()}
disabled={saving}
className="rounded px-2 py-1 text-xs font-medium hover:bg-muted disabled:opacity-50"
>
{saving ? <Loader2 className="h-3 w-3 animate-spin" /> : 'Save'}
</button>
<button
type="button"
onClick={() => {
setDraft(
e164 || country
? {
e164: e164 ?? null,
country: (country as CountryCode | null) ?? defaultCountry ?? 'US',
}
: null,
);
setEditing(false);
}}
disabled={saving}
className="rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-50"
>
Cancel
</button>
<div className="flex items-center justify-end gap-1.5">
<button
type="button"
onClick={() => {
setDraft(
e164 || country
? {
e164: e164 ?? null,
country: (country as CountryCode | null) ?? defaultCountry ?? 'US',
}
: null,
);
setEditing(false);
}}
disabled={saving}
className={cn(
'inline-flex h-8 items-center rounded-md px-3 text-xs font-medium',
'text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',
'disabled:opacity-50',
)}
>
Cancel
</button>
<button
type="button"
onClick={() => void commit()}
disabled={saving}
className={cn(
'inline-flex h-8 min-w-[64px] items-center justify-center rounded-md px-3',
'bg-primary text-xs font-semibold text-primary-foreground shadow-sm',
'transition-colors hover:bg-primary/90 disabled:opacity-50',
)}
>
{saving ? <Loader2 className="size-3.5 animate-spin" /> : 'Save'}
</button>
</div>
</div>
);
}