Keep suggested next steps inside their chips on a phone

This commit is contained in:
2026-11-22 15:30:41 +01:00
parent da6a73f740
commit 7460163287
2 changed files with 26 additions and 2 deletions
@@ -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(<BotSuggestionChip step={step} />);
}
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("[&amp;_.twui-button-content-wrapper]:whitespace-normal");
expect(html).toContain("[&amp;_.twui-button-content-wrapper]:min-w-0");
expect(html).toContain("break-words");
expect(html).toContain("max-w-full");
});
});
@@ -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 })}
>
<Span className="min-w-0">{step}</Span>
<Span className="min-w-0 break-words">{step}</Span>
<ArrowUpRight size={14} aria-hidden className="shrink-0" />
</Button>
);