GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): removing a thumbnail with the card open no longer strand… · pingdotgg/t3code@9bb5ad2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/src/features/threads
    • ThreadComposer.tsx
    • compactComposerLayout.test.ts
    • compactComposerLayout.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadComposer.tsx
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ export function useCompactComposerEditor(
201201
editorX.set(x);
202202
editorWidth.set(width);
203203
const compactWidth = Math.max(0, width - 8);
204+
const attachmentCount = state.rowAttachmentCount;
204205
setSlot((current) =>
205-
current.compactWidth === compactWidth ? current : { ...current, compactWidth },
206+
current.compactWidth === compactWidth && current.attachmentCount === attachmentCount
207+
? current
208+
: { ...current, compactWidth, attachmentCount },
206209
);
207210
}
208211
},
Collapse file

‎apps/mobile/src/features/threads/compactComposerLayout.test.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/compactComposerLayout.test.ts
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ function composer(
2323
readonly contentSize?: { readonly width: number; readonly height: number };
2424
readonly compactWidth?: number;
2525
readonly attachmentCount?: number;
26+
readonly measuredAttachmentCount?: number;
2627
} = {},
2728
) {
2829
const { isExpanded, modelIconOnly } = resolveCompactComposerLayout({
2930
slot: {
3031
...EMPTY_COMPACT_COMPOSER_SLOT,
3132
rowWidth: input.rowWidth ?? NARROW,
3233
compactWidth: input.compactWidth ?? 200,
34+
attachmentCount: input.measuredAttachmentCount ?? input.attachmentCount ?? 0,
3335
},
3436
isFocused: input.isFocused ?? false,
3537
isAndroid: input.isAndroid ?? false,
@@ -118,4 +120,16 @@ describe("compact composer layout", () => {
118120
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 160 });
119121
expect(composer({ ...line, compactWidth: slot.compactWidth }).isExpanded).toBe(false);
120122
});
123+
124+
it("re-measures a narrow row's slot when its thumbnail is removed with the card open", () => {
125+
const line = { value: "a short line", contentSize: { width: 150, height: LINE_HEIGHT } };
126+
const measuredWithThumbnail = { compactWidth: 138, measuredAttachmentCount: 1 };
127+
expect(composer({ ...line, ...measuredWithThumbnail, attachmentCount: 1 }).isExpanded).toBe(
128+
true,
129+
);
130+
expect(composer({ ...line, ...measuredWithThumbnail, attachmentCount: 0 }).isExpanded).toBe(
131+
false,
132+
);
133+
expect(composer({ ...line, compactWidth: 172 }).isExpanded).toBe(false);
134+
});
121135
});
Collapse file

‎apps/mobile/src/features/threads/compactComposerLayout.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/compactComposerLayout.ts
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ interface CompactComposerSlot {
88
readonly rowWidth: number;
99
/** The editor's collapsed width, or 0 until it is measured again. */
1010
readonly compactWidth: number;
11+
/** Thumbnails in the row when `compactWidth` was measured; it is stale for any other count. */
12+
readonly attachmentCount: number;
1113
readonly label: { readonly width: number; readonly isExpanded: boolean };
1214
}
1315

1416
export const EMPTY_COMPACT_COMPOSER_SLOT: CompactComposerSlot = {
1517
rowWidth: 0,
1618
compactWidth: 0,
19+
attachmentCount: 0,
1720
label: { width: 0, isExpanded: false },
1821
};
1922

@@ -64,7 +67,9 @@ export function resolveCompactComposerLayout(input: {
6467
readonly modelIconOnly: boolean;
6568
readonly labelShownAtRest: boolean;
6669
} {
67-
const { rowWidth, compactWidth } = input.slot;
70+
const { rowWidth } = input.slot;
71+
const compactWidth =
72+
input.slot.attachmentCount === input.rowAttachmentCount ? input.slot.compactWidth : 0;
6873
const isWide = isWideComposerRow(rowWidth);
6974
const opensOnFocus =
7075
rowWidth > 0 &&

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.