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(mobile): resilient solution for drawer height (#5783)

Peter Chinman926723abeb3c
diff --git a/apps/web/src/components/app/mobile/MobileDrawer.tsx b/apps/web/src/components/app/mobile/MobileDrawer.tsx
index db63045bd7..49bf6f23c8 100644
--- a/apps/web/src/components/app/mobile/MobileDrawer.tsx
+++ b/apps/web/src/components/app/mobile/MobileDrawer.tsx
@@ -44,12 +44,14 @@ export function scrollToFocusedInput(e: FocusEvent, offset = 40) {
* - Switches between `pb-(--safe-bottom)` and `pb-0` based on whether any
* input/textarea inside the drawer currently has focus (detected via
* bubbling focusin/focusout — no per-input wiring needed)
+ * - When a `MobileDrawer.ScrollBody` is present, hands the safe-area padding
+ * to it so the scroll viewport reaches the drawer's bottom edge
*
* Also handles default styling, which can be overridden via the `class` prop.
*/
function MobileDrawerContent(
props: ComponentProps<typeof Drawer.Content> & {
- /** Maximum height as a percentage of the viewport (vh). Clamped to 100. Defaults to 80. */
+ /** Maximum height as a percentage of the viewport (vh). Clamped to 100. Defaults to 80, or `targetHeight` when that is larger. */
maxHeight?: number;
/** Initial/start height as a percentage of the viewport (vh). Clamped to 100. Fits content when omitted. */
targetHeight?: number;
@@ -61,7 +63,8 @@ function MobileDrawerContent(
'targetHeight',
]);
- const maxHeight = () => Math.min(100, local.maxHeight ?? 80);
+ const maxHeight = () =>
+ Math.min(100, local.maxHeight ?? Math.max(80, local.targetHeight ?? 0));
const targetHeight = () =>
local.targetHeight != null ? Math.min(100, local.targetHeight) : undefined;
@@ -88,7 +91,7 @@ function MobileDrawerContent(
targetHeight() != null ? 'h-(--drawer-h)' : 'h-fit',
virtualKeyboardVisible()
? 'pb-0 max-h-[calc(var(--drawer-max-h)-var(--virtual-keyboard-height))] overflow-y-auto'
- : 'pb-(--safe-bottom)',
+ : 'pb-(--safe-bottom) has-[[data-drawer-scroll-body]]:pb-0',
local.class
)}
{...rest}
@@ -142,6 +145,42 @@ function MobileDrawerSection<T extends ValidComponent = 'div'>(
);
}
+/**
+ * Scrolling body for drawer content. Sits between the pinned chrome (Handle,
+ * headers) and the drawer's bottom edge, and scrolls when its sections
+ * outgrow the drawer's max height.
+ *
+ * `flex-auto` rather than `flex-1` on purpose: `Content` defaults to `h-fit`,
+ * and a basis-0 child of a fit-content flex column collapses the drawer to a
+ * sliver. `flex-auto` hugs content under `h-fit` and still fills the drawer
+ * when `targetHeight` makes its height definite.
+ *
+ * Takes over the safe-area padding from `Content` (via
+ * `data-drawer-scroll-body`): padding the drawer itself would end the scroll
+ * viewport above the home-indicator inset, so instead the scroll content is
+ * padded — the viewport reaches the drawer's bottom edge and the last item
+ * still clears the home indicator when scrolled to the end.
+ */
+function MobileDrawerScrollBody<T extends ValidComponent = 'div'>(
+ props: ExtendDiv<T>
+) {
+ const [local, rest] = splitProps(props, ['as', 'class', 'children']);
+ return (
+ <Dynamic
+ component={(local.as ?? 'div') as ValidComponent}
+ data-drawer-scroll-body
+ class={cn(
+ 'flex min-h-0 flex-auto flex-col overflow-y-auto',
+ !virtualKeyboardVisible() && 'pb-(--safe-bottom)',
+ local.class
+ )}
+ {...rest}
+ >
+ {local.children}
+ </Dynamic>
+ );
+}
+
/**
* Component for rendering the standard mobile drawer drag handle.
*/
@@ -180,6 +219,7 @@ export const MobileDrawer = Object.assign(
Overlay: Drawer.Overlay,
Content: MobileDrawerContent,
Close: Drawer.Close,
+ ScrollBody: MobileDrawerScrollBody,
Handle: MobileDrawerHandle,
Section: MobileDrawerSection,
Label: MobileDrawerSectionLabel,
diff --git a/apps/web/src/components/app/split-layout/components/SplitFileMenu.tsx b/apps/web/src/components/app/split-layout/components/SplitFileMenu.tsx
index a1e5e438af..caa2f5b33a 100644
--- a/apps/web/src/components/app/split-layout/components/SplitFileMenu.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitFileMenu.tsx
@@ -276,9 +276,7 @@ function MobileRender(
<MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />
<MobileDrawer.Content aria-label="File actions">
<MobileDrawer.Handle />
- {/* Scrolls when the sections outgrow the drawer's max height; the
- handle stays pinned so drag-to-dismiss remains reachable. */}
- <div class="flex flex-col min-h-0 flex-auto overflow-y-auto">
+ <MobileDrawer.ScrollBody>
<Show when={props.views}>
{(views) => (
<>
@@ -334,7 +332,7 @@ function MobileRender(
</>
)}
</For>
- </div>
+ </MobileDrawer.ScrollBody>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
diff --git a/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx b/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx
index 1863548601..7c67639cb1 100644
--- a/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx
+++ b/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx
@@ -202,37 +202,41 @@ export function OnboardingInbox() {
)}
</Show>
- <For each={drawerActionGroups()}>
- {(group, groupIndex) => (
- <>
- <Show when={groupIndex() > 0}>
- <div class="mt-3" />
- </Show>
- <Show when={group.label}>
- <MobileDrawer.Label>{group.label}</MobileDrawer.Label>
- </Show>
- <MobileDrawer.Section class="flex flex-col shrink-0">
- <For each={group.items}>
- {(action) => (
- <button
- type="button"
- class={cn(
- 'flex items-center gap-3 px-4 py-3 text-sm text-left not-last:mb-px bg-surface hover:bg-hover hover-transition-bg',
- action.destructive ? 'text-failure-ink' : 'text-ink'
- )}
- onClick={() => {
- action.onClick();
- closeDrawer();
- }}
- >
- {action.label}
- </button>
- )}
- </For>
- </MobileDrawer.Section>
- </>
- )}
- </For>
+ <MobileDrawer.ScrollBody>
+ <For each={drawerActionGroups()}>
+ {(group, groupIndex) => (
+ <>
+ <Show when={groupIndex() > 0}>
+ <div class="mt-3" />
+ </Show>
+ <Show when={group.label}>
+ <MobileDrawer.Label>{group.label}</MobileDrawer.Label>
+ </Show>
+ <MobileDrawer.Section class="flex flex-col shrink-0">
+ <For each={group.items}>
+ {(action) => (
+ <button
+ type="button"
+ class={cn(
+ 'flex items-center gap-3 px-4 py-3 text-sm text-left not-last:mb-px bg-surface hover:bg-hover hover-transition-bg',
+ action.destructive
+ ? 'text-failure-ink'
+ : 'text-ink'
+ )}
+ onClick={() => {
+ action.onClick();
+ closeDrawer();
+ }}
+ >
+ {action.label}
+ </button>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </>
+ )}
+ </For>
+ </MobileDrawer.ScrollBody>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
diff --git a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
index b3bf398531..36ae6a4d8e 100644
--- a/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
+++ b/apps/web/src/features/block-calendar/components/SelectedEventDetails.tsx
@@ -193,7 +193,7 @@ function EventDetailsDrawer(props: EventDetailsOverlayProps) {
</Show>
</div>
</div>
- <div class="flex min-h-0 flex-auto flex-col overflow-y-auto">
+ <MobileDrawer.ScrollBody>
<div class="px-3">
<EventDetails
event={props.event}
@@ -203,7 +203,7 @@ function EventDetailsDrawer(props: EventDetailsOverlayProps) {
</div>
<EventAttendeesSection attendees={props.event.attendees} />
<EventRsvpSection event={props.event} buttonSize="md" />
- </div>
+ </MobileDrawer.ScrollBody>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
diff --git a/apps/web/src/features/channel/Mobile/ActionDrawer.tsx b/apps/web/src/features/channel/Mobile/ActionDrawer.tsx
index b9efab1e14..b99ad13bea 100644
--- a/apps/web/src/features/channel/Mobile/ActionDrawer.tsx
+++ b/apps/web/src/features/channel/Mobile/ActionDrawer.tsx
@@ -252,55 +252,58 @@ export function ActionDrawer() {
</div>
</Show>
- {/* Non-destructive actions */}
- <Show when={nonDestructiveActions().length > 0}>
- <MobileDrawer.Section class="flex flex-col shrink-0">
- <For each={nonDestructiveActions()}>
- {(action) => (
- <button
- type="button"
- data-message-action={action.id}
- class="flex items-center gap-3 px-4 py-3 text-sm text-ink hover:bg-hover hover-transition-bg text-left not-last:mb-px bg-surface"
- ref={(el) => {
- const getTarget = action.getFocusTarget;
- if (getTarget) focusInput(el, () => ({ getTarget }));
- }}
- onClick={(event) => handleAction(action.onClick, event)}
- >
- <span class="size-5 flex items-center justify-center shrink-0">
- {renderIcon(action.icon)}
- </span>
- {action.label}
- </button>
- )}
- </For>
- </MobileDrawer.Section>
- </Show>
+ {/* Action sections scroll; the handle and reaction row stay pinned */}
+ <MobileDrawer.ScrollBody>
+ {/* Non-destructive actions */}
+ <Show when={nonDestructiveActions().length > 0}>
+ <MobileDrawer.Section class="flex flex-col shrink-0">
+ <For each={nonDestructiveActions()}>
+ {(action) => (
+ <button
+ type="button"
+ data-message-action={action.id}
+ class="flex items-center gap-3 px-4 py-3 text-sm text-ink hover:bg-hover hover-transition-bg text-left not-last:mb-px bg-surface"
+ ref={(el) => {
+ const getTarget = action.getFocusTarget;
+ if (getTarget) focusInput(el, () => ({ getTarget }));
+ }}
+ onClick={(event) => handleAction(action.onClick, event)}
+ >
+ <span class="size-5 flex items-center justify-center shrink-0">
+ {renderIcon(action.icon)}
+ </span>
+ {action.label}
+ </button>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </Show>
- {/* Destructive actions */}
- <Show when={destructiveActions().length > 0}>
- <MobileDrawer.Section class="flex flex-col shrink-0 mt-3">
- <For each={destructiveActions()}>
- {(action) => (
- <button
- type="button"
- data-message-action={action.id}
- class="flex items-center gap-3 px-4 py-3 text-sm text-failure-ink hover:bg-hover hover-transition-bg text-left not-last:mb-px bg-surface"
- ref={(el) => {
- const getTarget = action.getFocusTarget;
- if (getTarget) focusInput(el, () => ({ getTarget }));
- }}
- onClick={(event) => handleAction(action.onClick, event)}
- >
- <span class="size-5 flex items-center justify-center shrink-0">
- {renderIcon(action.icon)}
- </span>
- {action.label}
- </button>
- )}
- </For>
- </MobileDrawer.Section>
- </Show>
+ {/* Destructive actions */}
+ <Show when={destructiveActions().length > 0}>
+ <MobileDrawer.Section class="flex flex-col shrink-0 mt-3">
+ <For each={destructiveActions()}>
+ {(action) => (
+ <button
+ type="button"
+ data-message-action={action.id}
+ class="flex items-center gap-3 px-4 py-3 text-sm text-failure-ink hover:bg-hover hover-transition-bg text-left not-last:mb-px bg-surface"
+ ref={(el) => {
+ const getTarget = action.getFocusTarget;
+ if (getTarget) focusInput(el, () => ({ getTarget }));
+ }}
+ onClick={(event) => handleAction(action.onClick, event)}
+ >
+ <span class="size-5 flex items-center justify-center shrink-0">
+ {renderIcon(action.icon)}
+ </span>
+ {action.label}
+ </button>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </Show>
+ </MobileDrawer.ScrollBody>
</Show>
</MobileDrawer.Content>
</MobileDrawer.Portal>
diff --git a/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx b/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx
index b8bb11dd8a..d218eeaf0e 100644
--- a/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx
+++ b/apps/web/src/features/next-soup/soup-view/SoupEntityActionDrawer.tsx
@@ -63,9 +63,8 @@ export function SoupEntityActionDrawer() {
)}
</Show>
- {/* Action groups. Scrolls when the groups outgrow the drawer's max
- height; the handle and entity preview stay pinned. */}
- <div class="flex flex-col min-h-0 flex-auto overflow-y-auto">
+ {/* Action groups */}
+ <MobileDrawer.ScrollBody>
<For each={groups()}>
{(group, groupIndex) => (
<>
@@ -104,7 +103,7 @@ export function SoupEntityActionDrawer() {
</>
)}
</For>
- </div>
+ </MobileDrawer.ScrollBody>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PasteNode.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PasteNode.tsx
index 1087a6c63f..345cd517fb 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PasteNode.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PasteNode.tsx
@@ -201,7 +201,9 @@ export function PasteNode(props: PasteNodeDecoratorProps) {
</Button>
</div>
</div>
- <div class="flex-1 min-h-0 overflow-auto">{fullText()}</div>
+ <MobileDrawer.ScrollBody class="overflow-x-auto">
+ {fullText()}
+ </MobileDrawer.ScrollBody>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>