Clear the composer preview after sending a message. (#34116)

* Clear the composer preview after sending a message.

* fixup
This commit is contained in:
Will Hunt
2026-07-05 08:05:47 +00:00
committed by GitHub
parent a88b2e64c5
commit e994dbb419
3 changed files with 10 additions and 4 deletions
@@ -36,10 +36,14 @@ test.describe("Composer URL preview", () => {
);
await page.goto(`#/room/${room.roomId}`);
const composer = page.getByRole("textbox", { name: "Send an unencrypted message…" });
const composerRegion = page.getByRole("region", { name: "Message composer" });
const composer = composerRegion.getByRole("textbox", { name: "Send an unencrypted message…" });
await composer.pressSequentially("https://example.org/");
await expect(page.getByRole("link", { name: "Example Site" })).toBeVisible();
const preview = composerRegion.getByRole("link", { name: "Example Site" });
await expect(preview).toBeVisible();
await composer.press("Enter");
await expect(composer).toBeEmpty();
await expect(preview).toBeHidden();
});
test("does not show a preview when the server returns a 404", async ({ page, app, room }) => {
@@ -395,6 +395,7 @@ export class MessageComposer extends React.Component<IProps, IState> {
};
private sendMessage = async (): Promise<void> => {
this.setState({ urlPreviewComposerContent: "" });
if (this.state.haveRecording && this.voiceRecordingButton.current) {
// There shouldn't be any text message to send when a voice recording is active, so
// just send out the voice recording.
@@ -34,7 +34,8 @@ export function MessageComposerUrlPreviewWrapper({ content }: { content: string
void vm.updateWithText(content);
},
[vm, content],
DEBOUNCE_REQUEST_TIMEOUT_MS,
// Update instantly if content is empty (e.g. sent message or cleared input)
content ? DEBOUNCE_REQUEST_TIMEOUT_MS : 0,
);
useEffect(() => {