mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
fix(mobile): the checks the large-screen merge left red
- The trip's segmented control writes its fit through a ref, not into the element held in state (react-hooks/immutability). - The amount field of a payment uses the body type tier, which follows the text size setting, instead of a raw size. - The form sheet tests wait the frame the edge fade now measures on, and read the wide variant from the size class the shell writes. - The native dashes spec lists its locales through node:fs, so shared needs no vite types for it (knip). - Baselines lowered where the fixes removed warnings: no-misused-promises, no-non-null-assertion in tests, the MSheet rtl entry.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ChevronLeft, ChevronRight, FolderSync, List, Plus, Rows3 } from 'lucide-react';
|
||||
import { useLayoutEffect, useState, type ReactNode } from 'react';
|
||||
import { useCallback, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { canManageDocSync } from '../../../components/Files/docsync/useDocSync';
|
||||
import { useDocSyncOffered } from '../../../components/Files/docsync/useDocSyncOffered';
|
||||
import { useIsWide } from '../../../hooks/sizeClass';
|
||||
@@ -26,14 +26,21 @@ import { collabBoardFor, collabSideBySide } from './tabs/collabPanes';
|
||||
export function GlassSegment({ children, activeKey }: { children: ReactNode; activeKey?: string }) {
|
||||
const [region, setRegion] = useState<HTMLDivElement | null>(null);
|
||||
const [track, setTrack] = useState<HTMLDivElement | null>(null);
|
||||
// The element is also kept in a ref: the fit below writes to it, and state is not to be written.
|
||||
const trackRef = useRef<HTMLDivElement | null>(null);
|
||||
const attachTrack = useCallback((el: HTMLDivElement | null) => {
|
||||
trackRef.current = el;
|
||||
setTrack(el);
|
||||
}, []);
|
||||
const fade = useEdgeFade(track);
|
||||
useLayoutEffect(() => {
|
||||
if (!region || !track) return;
|
||||
const el = trackRef.current;
|
||||
if (!region || !el) return;
|
||||
const fit = () => {
|
||||
track.dataset.tight = 'false';
|
||||
track.dataset.tight = track.scrollWidth > track.clientWidth + 0.5 ? 'true' : 'false';
|
||||
const active = track.querySelector<HTMLElement>('[aria-pressed="true"]');
|
||||
if (active && track.scrollWidth > track.clientWidth + 0.5) {
|
||||
el.dataset.tight = 'false';
|
||||
el.dataset.tight = el.scrollWidth > el.clientWidth + 0.5 ? 'true' : 'false';
|
||||
const active = el.querySelector<HTMLElement>('[aria-pressed="true"]');
|
||||
if (active && el.scrollWidth > el.clientWidth + 0.5) {
|
||||
// 'nearest' on both axes: the shell root is fixed, anything else scrolls the page behind it.
|
||||
active.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
||||
}
|
||||
@@ -49,7 +56,7 @@ export function GlassSegment({ children, activeKey }: { children: ReactNode; act
|
||||
className="pointer-events-none absolute inset-y-0 end-12 start-12 flex items-center justify-center"
|
||||
>
|
||||
<div className="pointer-events-auto flex min-w-0 max-w-full rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] p-[3px] backdrop-blur-[24px] backdrop-saturate-[1.7]">
|
||||
<div ref={setTrack} className={`m-seg flex min-w-0 overflow-x-auto rounded-full ${edgeFadeClass(fade)}`}>
|
||||
<div ref={attachTrack} className={`m-seg flex min-w-0 overflow-x-auto rounded-full ${edgeFadeClass(fade)}`}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -182,7 +182,7 @@ export function AddPaymentSheet({
|
||||
onChange={(e) => setAmount(e.target.value)}
|
||||
placeholder={zeroAmountInput(currency)}
|
||||
aria-label={t('costs.amount')}
|
||||
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-[0.84375rem] font-semibold text-m-ink outline-none [font-variant-numeric:tabular-nums] placeholder:font-normal placeholder:text-m-faint"
|
||||
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-body font-semibold text-m-ink outline-none [font-variant-numeric:tabular-nums] placeholder:font-normal placeholder:text-m-faint"
|
||||
/>
|
||||
<span className="flex-none font-geist text-caption font-bold text-m-faint">{currency}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user