Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/mobile/src/native/T3ComposerEditor.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ interface NativeComposerEditorProps extends ViewProps {

const NativeView = requireNativeView<NativeComposerEditorProps>(NATIVE_MODULE_NAME);

// Fabric does not mount a `display: none` subtree, so a command sent while the composer slot is
// hidden (an open question) rejects with "Unable to find the view". There is nothing to act on.
function settleViewCommand(command: Promise<void> | undefined): void {
command?.catch(() => undefined);
}

function basename(path: string): string {
const separator = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
return separator >= 0 ? path.slice(separator + 1) : path;
Expand Down Expand Up @@ -159,10 +165,10 @@ export function ComposerEditor({
useImperativeHandle(
ref,
() => ({
focus: () => void nativeRef.current?.focus(),
blur: () => void nativeRef.current?.blur(),
focus: () => settleViewCommand(nativeRef.current?.focus()),
blur: () => settleViewCommand(nativeRef.current?.blur()),
setSelection: (nextSelection) =>
void nativeRef.current?.setSelection(nextSelection.start, nextSelection.end),
settleViewCommand(nativeRef.current?.setSelection(nextSelection.start, nextSelection.end)),
}),
[],
);
Expand Down
12 changes: 9 additions & 3 deletions apps/mobile/src/native/T3ComposerEditor.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ interface NativeComposerEditorProps extends ViewProps {

const NativeView = requireNativeView<NativeComposerEditorProps>(NATIVE_MODULE_NAME);

// Fabric does not mount a `display: none` subtree, so a command sent while the composer slot is
// hidden (an open question) rejects with "Unable to find the view". There is nothing to act on.
function settleViewCommand(command: Promise<void> | undefined): void {
command?.catch(() => undefined);
}

function basename(path: string): string {
const separator = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
return separator >= 0 ? path.slice(separator + 1) : path;
Expand Down Expand Up @@ -156,10 +162,10 @@ export function ComposerEditor({
useImperativeHandle(
ref,
() => ({
focus: () => void nativeRef.current?.focus(),
blur: () => void nativeRef.current?.blur(),
focus: () => settleViewCommand(nativeRef.current?.focus()),
blur: () => settleViewCommand(nativeRef.current?.blur()),
setSelection: (nextSelection) =>
void nativeRef.current?.setSelection(nextSelection.start, nextSelection.end),
settleViewCommand(nativeRef.current?.setSelection(nextSelection.start, nextSelection.end)),
}),
[],
);
Expand Down
Loading