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(email): Mobile scheduled send (#1972)

Evan Hutnik2d39ca98697a
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index e171e1ea14..3efba1d817 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -1629,6 +1629,7 @@ export function BaseInput(props: {
<EmailDateSelector
sendTime={form().sendTime() ?? null}
onSendTimeChange={handleSendTimeChange}
+ disablePortal={isMobile()}
/>
</Show>
<Show when={savedDraftId() && !laggedIsDraftSaving()}>
diff --git a/js/app/packages/block-email/component/date-selector.tsx b/js/app/packages/block-email/component/date-selector.tsx
index 5131213b9c..5c40c2ba26 100644
--- a/js/app/packages/block-email/component/date-selector.tsx
+++ b/js/app/packages/block-email/component/date-selector.tsx
@@ -40,11 +40,20 @@ type DateSelectorProps = {
disablePriorToDate?: Date;
disableAfterDate?: Date;
withTime?: boolean;
+ /** Render content inline instead of in a portal (avoids keyboard positioning issues on mobile) */
+ disablePortal?: boolean;
trigger?:
| JSX.Element
| ((props: { selectedDate: Date | null }) => JSX.Element);
};
+const DateSelectorPortalWrapper: FlowComponent<{ disabled?: boolean }> = (
+ props
+) => {
+ if (props.disabled) return <>{props.children}</>;
+ return <Combobox.Portal>{props.children}</Combobox.Portal>;
+};
+
export const DateSelector = (props: DateSelectorProps) => {
const [selectedOption, setSelectedOption] =
createSignal<DateSelectorOption | null>(
@@ -174,12 +183,14 @@ export const DateSelector = (props: DateSelectorProps) => {
setSelectedOption(option);
if (!option) {
props.onSelectDate?.(null);
+ onOpenChange(false);
return;
}
const dateValue = option.date;
props.onSelectDate?.(dateValue);
+ onOpenChange(false);
};
const options = createMemo(() => {
@@ -289,7 +300,7 @@ export const DateSelector = (props: DateSelectorProps) => {
</Combobox.Control>
</Show>
- <Combobox.Portal>
+ <DateSelectorPortalWrapper disabled={props.disablePortal}>
<Combobox.Content
class="w-full max-w-sm bg-dialog text-ink border border-edge-muted"
on:keydown={handleKeyDown}
@@ -365,7 +376,7 @@ export const DateSelector = (props: DateSelectorProps) => {
</div>
</WithCustomDateMode>
</Combobox.Content>
- </Combobox.Portal>
+ </DateSelectorPortalWrapper>
</Combobox>
);
};
@@ -393,6 +404,7 @@ const CurrentValueDisplay = (props: CurrentValueDisplayProps) => {
<span class="text-xs font-medium">{currentDateDisplay()}</span>
</div>
<button
+ onPointerDown={(e: PointerEvent) => e.preventDefault()}
onClick={props.onClear}
class="text-xs text-ink-muted hover:text-ink underline"
>
@@ -453,6 +465,11 @@ const DateSelectorItem: Component<
props.item.rawValue.type === 'select-custom' &&
'border-t border-edge-muted'
)}
+ onPointerDown={(e: PointerEvent) => {
+ // Prevent default to stop input blur on mobile, which would close the
+ // combobox before the selection click event fires.
+ e.preventDefault();
+ }}
>
<Combobox.ItemIndicator class="hidden" />
<div class="flex items-center gap-2 flex-1 min-w-0">
diff --git a/js/app/packages/block-email/component/email-date-selector.tsx b/js/app/packages/block-email/component/email-date-selector.tsx
index fa38e576db..c641565979 100644
--- a/js/app/packages/block-email/component/email-date-selector.tsx
+++ b/js/app/packages/block-email/component/email-date-selector.tsx
@@ -6,27 +6,35 @@ import { format } from 'date-fns/format';
import { Show, type VoidComponent } from 'solid-js';
import IconX from '@icon/regular/x.svg';
import { Button } from '@ui/components/Button';
+import { isMobile } from '@core/mobile/isMobile';
+import { cn } from '@ui/utils/classname';
interface EmailDateSelectorProps {
sendTime?: Date | null;
onSendTimeChange?: (date: Date | null) => void;
/** Only show the clock icon, no date text or clear button */
compact?: boolean;
+ /** Render content inline instead of in a portal */
+ disablePortal?: boolean;
}
export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (
props
) => {
+ const isCompact = () => props.compact || isMobile();
+
return (
<DateSelector
selectedDate={props.sendTime}
onSelectDate={props.onSendTimeChange}
disablePriorToDate={new Date()}
disableAfterDate={addYears(new Date(), 1)}
+ disablePortal={props.disablePortal}
trigger={(state) => {
const formattedDate = () => {
if (!state.selectedDate) return;
return format(state.selectedDate, 'MMM d, yyyy h:mm a');
};
+ const showExpanded = () => !isCompact() && !!formattedDate();
return (
<Tooltip
tooltip={
@@ -34,10 +42,19 @@ export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (
? `Scheduled for ${formattedDate()}`
: 'Schedule this email'
}
+ hide={showExpanded()}
>
- <Button size="icon-sm">
- <ClockIcon />
- <Show when={!props.compact && formattedDate()}>
+ <Button
+ size="icon-sm"
+ class={cn(
+ showExpanded() &&
+ 'size-auto gap-1 bg-accent/20 text-accent-ink hover:!bg-accent/15 hover:!text-accent-ink'
+ )}
+ >
+ <ClockIcon
+ class={state.selectedDate && isCompact() ? 'text-accent' : ''}
+ />
+ <Show when={showExpanded()}>
<span class="text-sm">{formattedDate()}</span>
<Tooltip tooltip="Clear">
<div