Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Chat): render ChatLayoutScrollButton icon-only in its default state (#4854)

Ojas Mutreja0bb5f3d1956b
diff --git a/.changeset/chat-layout-scroll-button-icon-only.md b/.changeset/chat-layout-scroll-button-icon-only.md
new file mode 100644
index 0000000000..fbb9ba8e26
--- /dev/null
+++ b/.changeset/chat-layout-scroll-button-icon-only.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] ChatLayoutScrollButton: the default (label-less) state now renders as icon-only, with the translated "Scroll to bottom" string as the accessible name only. It was previously missing `isIconOnly` on its inner `Button`, so Button's default (visible-text) contract rendered the translation as clipped visible text inside the circular button instead.
+
+@HelloOjasMutreja
diff --git a/packages/core/src/Chat/ChatLayoutScrollButton.test.tsx b/packages/core/src/Chat/ChatLayoutScrollButton.test.tsx
index 2708d25cd6..e7031996da 100644
--- a/packages/core/src/Chat/ChatLayoutScrollButton.test.tsx
+++ b/packages/core/src/Chat/ChatLayoutScrollButton.test.tsx
@@ -16,6 +16,28 @@ describe('ChatLayoutScrollButton', () => {
expect(screen.getByTestId('scroll')).toBeTruthy();
});
+ it('renders icon-only (no visible label text) in the default, label-less state', () => {
+ render(<ChatLayoutScrollButton isVisible onClick={() => {}} />);
+ const button = screen.getByRole('button', {name: 'Scroll to bottom'});
+ // The translated name must stay accessible-only. Button renders visible
+ // text whenever isIconOnly is false (its default), so a missing
+ // isIconOnly here previously rendered the full translation as clipped
+ // visible text inside the circular button instead of just the chevron.
+ expect(button.textContent).toBe('');
+ });
+
+ it('renders the label as visible text when provided', () => {
+ render(
+ <ChatLayoutScrollButton
+ isVisible
+ onClick={() => {}}
+ label="New messages"
+ />,
+ );
+ const button = screen.getByRole('button', {name: 'New messages'});
+ expect(button).toHaveTextContent('New messages');
+ });
+
it('forwards rest props (data-*, aria-*, id) to the root element', () => {
render(
<ChatLayoutScrollButton
diff --git a/packages/core/src/Chat/ChatLayoutScrollButton.tsx b/packages/core/src/Chat/ChatLayoutScrollButton.tsx
index e6ca5ba5da..db30ba6b9b 100644
--- a/packages/core/src/Chat/ChatLayoutScrollButton.tsx
+++ b/packages/core/src/Chat/ChatLayoutScrollButton.tsx
@@ -144,6 +144,7 @@ export function ChatLayoutScrollButton({
icon={<Icon icon="chevronDown" size="md" />}
variant="ghost"
size="md"
+ isIconOnly={!label}
onClick={onClick}
xstyle={[styles.button, label ? styles.buttonWithLabel : null]}>
{label ?? undefined}