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(ios): mobile touch menus (#4787)

Peter Chinmanbfa588a16047
diff --git a/apps/web/src/components/app/mobile/MobileDock.tsx b/apps/web/src/components/app/mobile/MobileDock.tsx
index 088d494608..8c93a03c5d 100644
--- a/apps/web/src/components/app/mobile/MobileDock.tsx
+++ b/apps/web/src/components/app/mobile/MobileDock.tsx
@@ -129,7 +129,6 @@ function MoreViewsMenu(props: {
return (
<MobileTouchMenu
triggerIcon={CaretUpIcon}
- triggerAriaLabel="More views"
footerLabel="Views"
footerCaretClass="mr-11"
items={[
@@ -179,7 +178,6 @@ function CreateMenu() {
return (
<MobileTouchMenu
triggerIcon={PlusIcon}
- triggerAriaLabel="Create"
footerLabel="Create"
items={[
uploadItem,
diff --git a/apps/web/src/components/app/mobile/MobileTouchMenu.tsx b/apps/web/src/components/app/mobile/MobileTouchMenu.tsx
index 1c6dbcf2b9..bbfa7a2608 100644
--- a/apps/web/src/components/app/mobile/MobileTouchMenu.tsx
+++ b/apps/web/src/components/app/mobile/MobileTouchMenu.tsx
@@ -45,14 +45,12 @@ export type MobileTouchMenuTriggerProps = {
type MobileTouchMenuButtonProps = {
icon: MobileTouchIconComponent;
- ariaLabel: string;
ref?: HTMLButtonElement | ((el: HTMLButtonElement) => void);
- onClick: () => void;
+ onPointerDown: () => void;
onTouchMove?: (e: TouchEvent) => void;
onTouchEnd?: (e: TouchEvent) => void;
class?: string;
animateIcon?: boolean;
- fireOnPress?: boolean;
};
function MobileTouchMenuButton(props: MobileTouchMenuButtonProps) {
@@ -62,23 +60,15 @@ function MobileTouchMenuButton(props: MobileTouchMenuButtonProps) {
<button
type="button"
ref={props.ref}
- aria-label={props.ariaLabel}
use:pressPulse
- onPointerDown={() => {
+ onPointerDown={(e) => {
+ e.preventDefault();
hapticImpact('light');
if (props.animateIcon !== false) {
setAnimating(true);
setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
}
- if (props.fireOnPress) props.onClick();
- }}
- onClick={(e) => {
- if (props.fireOnPress) {
- // Keyboard/assistive activation dispatches click without pointerdown.
- if (e.detail === 0) props.onClick();
- return;
- }
- props.onClick();
+ props.onPointerDown();
}}
onTouchMove={props.onTouchMove}
onTouchEnd={props.onTouchEnd}
@@ -98,27 +88,8 @@ function MobileTouchMenuButton(props: MobileTouchMenuButtonProps) {
);
}
-// Touch menu triggers open on pointer-down, which also arms the
-// hold-and-drag-to-select gesture. Swallow the opening touch's trailing
-// synthesized click so it cannot accidentally select a freshly-mounted row.
-function suppressNextClick() {
- const onClick = (e: MouseEvent) => {
- e.stopPropagation();
- e.preventDefault();
- cleanup();
- };
- const cleanup = () => {
- document.removeEventListener('click', onClick, true);
- clearTimeout(timer);
- };
- const timer = setTimeout(cleanup, 400);
- document.addEventListener('click', onClick, true);
-}
-
export function MobileTouchMenu(props: {
- triggerIcon?: MobileTouchIconComponent;
- triggerAriaLabel: string;
- trigger?: (props: MobileTouchMenuTriggerProps) => JSXElement;
+ triggerIcon: MobileTouchIconComponent;
position?: 'bottom-row' | 'trigger-bottom';
footerLabel: string;
footerCaretClass?: string;
@@ -158,7 +129,6 @@ export function MobileTouchMenu(props: {
syncTriggerPosition();
setMounted(true);
setOpen(true);
- suppressNextClick();
};
const closeMenu = () => {
@@ -206,41 +176,17 @@ export function MobileTouchMenu(props: {
select(id);
};
- const triggerProps = (): MobileTouchMenuTriggerProps => ({
- open: open(),
- ref: setTriggerRef,
- onPointerDown: () => {
- hapticImpact('light');
- toggleMenu();
- },
- onClick: (e) => {
- // Keyboard/assistive activation dispatches click without pointerdown.
- if (e.detail === 0) toggleMenu();
- },
- onTouchMove: handleTouchMove,
- onTouchEnd: handleTouchEnd,
- });
-
return (
<>
- <Show
- when={props.trigger}
- fallback={
- <MobileTouchMenuButton
- ref={setTriggerRef}
- icon={props.triggerIcon!}
- ariaLabel={props.triggerAriaLabel}
- animateIcon={false}
- fireOnPress
- onClick={toggleMenu}
- onTouchMove={handleTouchMove}
- onTouchEnd={handleTouchEnd}
- class="size-10 rounded-full"
- />
- }
- >
- {(trigger) => trigger()(triggerProps())}
- </Show>
+ <MobileTouchMenuButton
+ ref={setTriggerRef}
+ icon={props.triggerIcon}
+ animateIcon={false}
+ onPointerDown={toggleMenu}
+ onTouchMove={handleTouchMove}
+ onTouchEnd={handleTouchEnd}
+ class="size-10 rounded-full"
+ />
<Show when={mounted()}>
<Portal>
{/* Portaled to <body>, outside FloatRegionHost's Layer. Re-apply
@@ -323,7 +269,7 @@ export function MobileTouchMenu(props: {
<button
type="button"
class="flex h-9 shrink-0 items-center justify-between px-3 text-sm font-medium text-ink-muted"
- onClick={() => {
+ onPointerDown={() => {
hapticImpact('light');
closeMenu();
}}
diff --git a/apps/web/src/components/app/mobile/PillTabs.tsx b/apps/web/src/components/app/mobile/PillTabs.tsx
index acfcae2680..5cf00bf03e 100644
--- a/apps/web/src/components/app/mobile/PillTabs.tsx
+++ b/apps/web/src/components/app/mobile/PillTabs.tsx
@@ -39,11 +39,6 @@ export function PillTabs<T extends string>(props: {
items: readonly PillTabItem<T>[];
value: T | undefined;
onChange: (value: T) => void;
- /**
- * Keep the active element focused when a pill is tapped (e.g. so an open
- * keyboard stays up in search) by preventing the pointer-down default.
- */
- preserveFocus?: boolean;
/** Extra classes on the scroll strip. */
class?: string;
}) {
@@ -164,7 +159,7 @@ export function PillTabs<T extends string>(props: {
: 'text-ink-extra-muted'
)}
onPointerDown={(e) => {
- if (props.preserveFocus) e.preventDefault();
+ e.preventDefault();
hapticImpact('light');
}}
onClick={() => props.onChange(item.value)}
@@ -176,7 +171,7 @@ export function PillTabs<T extends string>(props: {
</For>
<Show when={overflowItems().length > 0}>
<MobileTouchMenu
- triggerAriaLabel="More tabs"
+ triggerIcon={DotsThreeIcon}
position="trigger-bottom"
footerLabel="Tabs"
items={overflowItems().map((item) => ({
@@ -185,24 +180,6 @@ export function PillTabs<T extends string>(props: {
active: () => props.value === item.value,
onSelect: () => props.onChange(item.value),
}))}
- trigger={(trigger) => (
- <button
- type="button"
- use:pressPulse
- ref={trigger.ref}
- aria-label="More tabs"
- class="h-10 w-10 shrink-0 rounded-full text-ink-extra-muted island flex items-center justify-center [&_svg]:size-5"
- onPointerDown={(e) => {
- if (props.preserveFocus) e.preventDefault();
- trigger.onPointerDown();
- }}
- onClick={trigger.onClick}
- onTouchMove={trigger.onTouchMove}
- onTouchEnd={trigger.onTouchEnd}
- >
- <DotsThreeIcon />
- </button>
- )}
/>
</Show>
<div
diff --git a/apps/web/src/features/command/mobile/MobileSearch.tsx b/apps/web/src/features/command/mobile/MobileSearch.tsx
index 8f70f4e46d..a0c2a7f0eb 100644
--- a/apps/web/src/features/command/mobile/MobileSearch.tsx
+++ b/apps/web/src/features/command/mobile/MobileSearch.tsx
@@ -456,7 +456,6 @@ function CategoryFilterTabs() {
items={CATEGORIES}
value={SearchState.categoryFilter()}
onChange={(value) => SearchState.setCategoryFilter(value)}
- preserveFocus
/>
</div>
);