Skip to content

Commit 95a341a

Browse files
fix: Overflowing content expands the chat bubble horizontally (#50)
* fix: Overflowing content expands the chat bubble horizontally * fix unnecessary vertical scrollbar
1 parent 35fbff4 commit 95a341a

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"devDependencies": {
6161
"@cloudscape-design/browser-test-tools": "^3.0.4",
6262
"@cloudscape-design/build-tools": "^3.0.1",
63+
"@cloudscape-design/code-view": "^3",
6364
"@cloudscape-design/components": "^3",
6465
"@cloudscape-design/design-tokens": "^3",
6566
"@cloudscape-design/documenter": "^1.0.0",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import CodeView from "@cloudscape-design/code-view/code-view";
5+
6+
import { ChatBubble } from "../../lib/components";
7+
import { TestBed } from "../app/test-bed";
8+
import smiley from "../avatar/smiley.png";
9+
import { ScreenshotArea } from "../screenshot-area";
10+
import { ChatBubbleAvatarGenAI, ChatContainer } from "./util-components";
11+
12+
export default function ChatBubbleWithOverflowPage() {
13+
return (
14+
<ScreenshotArea>
15+
<h1>Chat bubble with overflowing content</h1>
16+
<p>
17+
These chat bubbles have content that is wider than the available space. The chat bubbles should render a scroll
18+
bar.
19+
</p>
20+
21+
<TestBed>
22+
<ChatContainer>
23+
<ChatBubble type="incoming" avatar={<ChatBubbleAvatarGenAI />} ariaLabel="Gen AI at 4:24:25pm">
24+
This is a regular chat bubble with small content.
25+
</ChatBubble>
26+
27+
<ChatBubble type="incoming" avatar={<ChatBubbleAvatarGenAI />} ariaLabel="Gen AI at 4:24:25pm">
28+
This chat bubble contains some code.
29+
<CodeView content="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." />
30+
</ChatBubble>
31+
32+
<ChatBubble type="incoming" avatar={<ChatBubbleAvatarGenAI />} ariaLabel="Gen AI at 4:24:26pm">
33+
This chat bubble contains an image.
34+
<img src={smiley} width={3000} height={200} />
35+
</ChatBubble>
36+
</ChatContainer>
37+
</TestBed>
38+
</ScreenshotArea>
39+
);
40+
}

src/chat-bubble/styles.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
flex-direction: column;
2323
gap: cs.$space-scaled-s;
2424
padding: cs.$space-scaled-s;
25+
min-width: 0;
26+
overflow-x: auto;
2527

2628
border-start-start-radius: cs.$border-radius-chat-bubble;
2729
border-start-end-radius: cs.$border-radius-chat-bubble;

0 commit comments

Comments
 (0)