From 7f74dfd143d5fbbd7fc775a91f072fe85ecc496b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 31 Mar 2026 21:27:04 -0500 Subject: [PATCH] In a pretty good state, but might need to just go monolith --- src/components/Autocomplete/Autocomplete.tsx | 7 +- .../Autocomplete/useAutocomplete.ts | 3 + src/components/Composer/index.tsx | 89 ++++++++++--------- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/src/components/Autocomplete/Autocomplete.tsx b/src/components/Autocomplete/Autocomplete.tsx index afc17c9fba..1a4e441369 100644 --- a/src/components/Autocomplete/Autocomplete.tsx +++ b/src/components/Autocomplete/Autocomplete.tsx @@ -43,7 +43,12 @@ export function Autocomplete({ a.border, t.atoms.border_contrast_low, t.atoms.bg, - !IS_WEB && a.w_full, + a.w_full, + IS_WEB + ? { + maxWidth: 300, + } + : {}, ]} render={render} /> diff --git a/src/components/Autocomplete/useAutocomplete.ts b/src/components/Autocomplete/useAutocomplete.ts index 191eaabe59..e87c61f14c 100644 --- a/src/components/Autocomplete/useAutocomplete.ts +++ b/src/components/Autocomplete/useAutocomplete.ts @@ -44,6 +44,9 @@ export function useAutocomplete({ // TODO return recents if (!query) return [] + // Going from "foo" to "foo." should not clear matches. + query = query.toLowerCase().trim().replace(/\.$/, '') + const res = await agent.searchActorsTypeahead({ q: query, limit: limit || 8, diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index 4170db21ba..590816ea23 100644 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -161,10 +161,12 @@ export function Root({ const callbackRefs = useRef({ onActiveFacetOuter, onFacetCommittedOuter, + focus: tapper.input.focus, }) callbackRefs.current = { onActiveFacetOuter, onFacetCommittedOuter, + focus: tapper.input.focus, } useImperativeHandle( @@ -200,9 +202,13 @@ export function Root({ const offFacetCommitted = tapper.on('facetCommitted', facet => { callbackRefs.current.onFacetCommittedOuter?.(facet) }) + const offAfterInsert = tapper.on('afterInsert', () => { + callbackRefs.current?.focus() + }) return () => { offActiveFacet() offFacetCommitted() + offAfterInsert() } }, [tapper.on]) @@ -303,6 +309,15 @@ export function Input({ ? {height: lineHeight + verticalSpace} : {minHeight: mh, maxHeight: xh} + /* + * On iOS especially, TextInput and Text line height does not render the + * same way, but setting this to undefined and using the default font + * metrics works fine. + */ + if (!IS_WEB) { + delete ts.lineHeight + } + return {textStyle: ts, textAreaStyle: tas, minHeight: mh, maxHeight: xh} }, [t, fonts, padding, rawTextStyle, initialNumberOfLines, maxNumberOfLines]) @@ -361,43 +376,39 @@ export function Input({ [onRequestSubmit], ) - const textContent = ( - - {state.nodes.map((node, i) => { - switch (node.type) { - case 'text': - return {node.value} - case 'trigger': - case 'facet': - return ( - - {node.raw} - - ) - } - })} - - ) - return ( - {IS_WEB && ( - - - {textContent} - - - )} + + + + {state.nodes.map((node, i) => { + switch (node.type) { + case 'text': + return {node.value} + case 'trigger': + case 'facet': + return ( + + {node.raw} + + ) + } + })} + + + { isComposing.current = false - }}> - {IS_WEB ? null : textContent} - + }} + /> ) } @@ -514,7 +523,7 @@ function AutocompleteInner({ query: activeFacet.value, }) - return data ? ( + return data && data.length ? (