From 49a792e468061be6d40ab8d07db8ff902318287d Mon Sep 17 00:00:00 2001 From: Daniel Lu Date: Tue, 20 Oct 2026 11:41:47 -0700 Subject: [PATCH] fix: have card type attachments render at full width so file name and description are visible --- .../ai/chromatic/AttachmentList.stories.tsx | 216 ++++++++++++++++++ .../@react-spectrum/ai/src/AttachmentList.tsx | 6 +- 2 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 packages/@react-spectrum/ai/chromatic/AttachmentList.stories.tsx diff --git a/packages/@react-spectrum/ai/chromatic/AttachmentList.stories.tsx b/packages/@react-spectrum/ai/chromatic/AttachmentList.stories.tsx new file mode 100644 index 00000000000..db1a14461b6 --- /dev/null +++ b/packages/@react-spectrum/ai/chromatic/AttachmentList.stories.tsx @@ -0,0 +1,216 @@ +/* + * Copyright 2026 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import { + Attachment as AttachmentComponent, + AttachmentList, + AttachmentPreview +} from '../src/AttachmentList'; +import {Content} from '@react-spectrum/s2/Content'; +import type {Meta, StoryObj} from '@storybook/react'; +import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; +import {Text} from '@react-spectrum/s2/Text'; + +const meta: Meta = { + parameters: { + chromaticProvider: { + disableAnimations: true, + colorSchemes: ['light', 'dark'], + locales: ['en-US'] + } + }, + title: 'AI Chromatic/AttachmentList' +}; + +export default meta; + +type Story = StoryObj; + +export const attachmentVariants: Story = { + render: () => ( +
+ + + + + + + + + + + + + Design review.pdf + PDF document + + + + + + data.csv + + + +
+ ) +}; + +export const LongContents: Story = { + name: 'Long contents', + render: () => ( + + + + + Very long file name that exceeds the container width.pdf + + Long long long long long long long long long long description. + + + + + ) +}; + +export const MixedAttachments: Story = { + name: 'Mixed attachments', + render: () => ( +
+ + + + + + + + + + + + + + + + + + + banner.png + PNG image + + + + + + notes.txt + Plain text + + + + + + video.mp4 + MP4 + + + + + + debug.zip + ZIP + + + +
+ ) +}; + +export const Carousels: Story = { + name: 'Carousels', + render: () => ( +
+ + {Array.from({length: 8}, (_, i) => ( + + + + ))} + + + {Array.from({length: 6}, (_, i) => ( + + + + {`Card file ${i + 1}.pdf`} + PDF + + + ))} + +
+ ) +}; diff --git a/packages/@react-spectrum/ai/src/AttachmentList.tsx b/packages/@react-spectrum/ai/src/AttachmentList.tsx index 13e323b2370..49a57c6b085 100644 --- a/packages/@react-spectrum/ai/src/AttachmentList.tsx +++ b/packages/@react-spectrum/ai/src/AttachmentList.tsx @@ -117,6 +117,7 @@ const closeButton = style<{ disableTapHighlight: true }); +const hasContent = ':has([data-slot=content])'; const onlyPreview = ':not(:has([data-slot=content])):not(:has([data-slot=preview]))'; const container = { @@ -577,7 +578,10 @@ export interface AttachmentProps const tagStyles = style({ flexShrink: 0, flexGrow: 0, - flexBasis: '0%', + flexBasis: { + default: '0%', + [hasContent]: 'auto' + }, position: 'relative', ...focusRing(), borderRadius: 'lg',