Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix[channels]: jump to reply input on tab focus (#434)
Peter Chinman9448d90c39b7
diff --git a/js/app/packages/block-channel/component/BaseInput.tsx b/js/app/packages/block-channel/component/BaseInput.tsxindex ea90475920..8bcf9e3dcf 100644--- a/js/app/packages/block-channel/component/BaseInput.tsx+++ b/js/app/packages/block-channel/component/BaseInput.tsx@@ -20,13 +20,13 @@ import {STATIC_VIDEO,} from '@core/store/cacheChannelInput';import type { IUser } from '@core/user';+import ArrowUp from '@icon/bold/arrow-up-bold.svg';+import Spinner from '@icon/bold/spinner-gap-bold.svg';import PlusIcon from '@icon/regular/plus.svg';import FormatIcon from '@icon/regular/text-aa.svg';+import Trash from '@icon/regular/trash.svg';import XIcon from '@icon/regular/x.svg';import { logger } from '@observability';-import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';-import ArrowFatLineUp from '@phosphor-icons/core/fill/arrow-fat-line-up-fill.svg?component-solid';-import Trash from '@phosphor-icons/core/regular/trash.svg?component-solid';import type { SimpleMention } from '@service-comms/generated/models/simpleMention';import { createCallback } from '@solid-primitives/rootless';import { leading, throttle } from '@solid-primitives/scheduled';@@ -82,7 +82,10 @@ type BaseInputProps = {/** external focus trigger: if getter returns true, focus then call clearer */shouldFocus?: boolean;clearShouldFocus?: () => void;+ onFocus?: () => void;+ onBlur?: () => void;/** called after onSend resolves and after BaseInput cleanup */+afterSend?: () => void | Promise<void>;/** called when the user uses the up arrow or shift + tab to leave the first line of input */onFocusLeaveStart?: (e: KeyboardEvent) => void;@@ -215,6 +218,19 @@ export function BaseInput(props: BaseInputProps) {}}, 0);}++ if (ref() && props.onFocus) {+ const markdownElement = ref()!;+ const handleFocusIn = () => {+ props.onFocus?.();+ };++ markdownElement.addEventListener('focusin', handleFocusIn);++ onCleanup(() => {+ markdownElement.removeEventListener('focusin', handleFocusIn);+ });+ }});const onFocusLeaveEnd = (e: KeyboardEvent) => {@@ -449,6 +465,7 @@ export function BaseInput(props: BaseInputProps) {}}onBlur={() => {+ props.onBlur?.();stopTyping();handleBlur();}}@@ -536,22 +553,16 @@ export function BaseInput(props: BaseInputProps) {onClick={() => {handleSend();}}- class="text-ink-muted bg-transparent rounded-full hover:scale-110! transition ease-in-out delay-150 flex flex-col justify-center items-center"+ class="text-ink-muted hover:scale-115 transition ease-in-out flex flex-col justify-center items-center size-6 rounded-full">- <div class="bg-transparent rounded-full size-8 flex flex-row justify-center items-center">- <Show- when={!hasPendingAttachments() && !isPendingSend()}- fallback={- <Spinner class="w-5 h-5 animate-spin cursor-disabled" />- }- >- <ArrowFatLineUp- width={20}- height={20}- class="!text-accent-ink !fill-accent"- />- </Show>- </div>+ <Show+ when={!hasPendingAttachments() && !isPendingSend()}+ fallback={<Spinner class="size-6 animate-spin cursor-disabled" />}+ >+ <div class="group hover:bg-accent transition ease-in-out size-6 border border-accent rounded-full flex items-center justify-center">+ <ArrowUp class="group-hover:!text-input group-hover:!fill-input !text-accent-ink !fill-accent size-4 transition ease-in-out" />+ </div>+ </Show></button></div></div>diff --git a/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx b/js/app/packages/block-channel/component/ReplyInputsPortaler.tsxindex 3afdbf786b..a94669e422 100644--- a/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx+++ b/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx@@ -11,7 +11,13 @@ import { blockElementSignal } from '@core/signal/blockElement';import type { InputAttachment } from '@core/store/cacheChannelInput';import type { Message } from '@service-comms/generated/models';import { createCallback } from '@solid-primitives/rootless';-import { type Accessor, createEffect, For, type Setter } from 'solid-js';+import {+ type Accessor,+ createEffect,+ createSignal,+ For,+ type Setter,+} from 'solid-js';import type { SetStoreFunction } from 'solid-js/store';import { Portal } from 'solid-js/web';import type { VirtualizerHandle } from 'virtua/solid';@@ -36,6 +42,9 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {const sendMessage_ = createCallback(sendMessage);const blockRef = blockElementSignal.get;+ const [focusedReplyInputThreadId, setFocusedReplyInputThreadId] =+ createSignal<string>();+const onSend =(threadId: string) => async (args: Parameters<typeof sendMessage>[0]) => {clearDraftMessage(props.channelId, threadId);@@ -104,6 +113,8 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {(lastMessageBody as HTMLElement).focus();};+ let replyFocusTimeout: ReturnType<typeof setTimeout> | undefined;+return (<Foreach={Object.keys(props.threadViewStore).filter(@@ -115,6 +126,7 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {// TODO: this should only fire if this reply input was focusedcreateEffect((prev) => {if (+ focusedReplyInputThreadId() === threadId &&props.threadViewStore[threadId].replyInputMountTarget &&prev &&prev !== props.threadViewStore[threadId].replyInputMountTarget@@ -153,6 +165,15 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {replyInputShouldFocus: false,}))}+ onFocus={() => {+ if (replyFocusTimeout) clearTimeout(replyFocusTimeout);+ setFocusedReplyInputThreadId(threadId);+ }}+ onBlur={() => {+ replyFocusTimeout = setTimeout(() => {+ setFocusedReplyInputThreadId(undefined);+ }, 100);+ }}onStartTyping={() => postTypingUpdate_('start', threadId)}onStopTyping={() => postTypingUpdate_('stop', threadId)}inputAttachments={{