From 74601632879474d477edd39ddb0ce72d85e62474 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Sun, 22 Nov 2026 15:30:41 +0100 Subject: [PATCH] Keep suggested next steps inside their chips on a phone --- .../bot-suggestion-chip.render.test.tsx | 24 +++++++++++++++++++ .../(partials)/bot-suggestion-chip.tsx | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx diff --git a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx new file mode 100644 index 00000000..71dff257 --- /dev/null +++ b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.render.test.tsx @@ -0,0 +1,24 @@ +import { describe, expect, test } from "bun:test"; +import { renderToString } from "react-dom/server"; +import BotSuggestionChip from "./bot-suggestion-chip"; + +const longStep = + "Write a full launch plan for next quarter with owners, deadlines and the review checkpoints for every team"; + +function render({ step }: { step: string }) { + return renderToString(); +} + +describe("BotSuggestionChip", () => { + test("shows the step and keeps it inside the chip", () => { + const html = render({ step: longStep }); + + expect(html).toContain(longStep); + // The twui button's content wrapper is nowrap by default, which let a + // long step spill out of the button's outline on a phone. + expect(html).toContain("[&_.twui-button-content-wrapper]:whitespace-normal"); + expect(html).toContain("[&_.twui-button-content-wrapper]:min-w-0"); + expect(html).toContain("break-words"); + expect(html).toContain("max-w-full"); + }); +}); \ No newline at end of file diff --git a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx index 98571cdd..02b8757c 100644 --- a/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx +++ b/src/pages/admin/bots/[bot_id]/(partials)/bot-suggestion-chip.tsx @@ -22,10 +22,10 @@ export default function BotSuggestionChip({ step }: Props) { color="gray" size="smaller" title={`Put this in your input: ${step}`} - className="inline-flex h-auto max-w-full gap-1! flex-nowrap align-middle px-2! py-1! text-left text-[13px] font-normal whitespace-normal [&_.twui-button-content-wrapper]:min-w-0" + className="inline-flex h-auto max-w-full min-w-0 gap-1! flex-nowrap align-middle px-2! py-1! text-left text-[13px] font-normal whitespace-normal [&_.twui-button-content-wrapper]:min-w-0 [&_.twui-button-content-wrapper]:whitespace-normal" onClick={() => onUseSuggestion({ text: step })} > - {step} + {step} );