Skip to content

Commit c39b3bf

Browse files
committed
[Component Audit] Divider: keep numeric labels visible and named
1 parent 9025ab3 commit c39b3bf

7 files changed

Lines changed: 201 additions & 71 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] `Divider` now keeps numeric zero labels inside the labelled separator and omits boolean or empty-string labels without leaving empty label spacing.
6+
7+
@cixzhang

‎apps/storybook/stories/Divider.stories.tsx‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,15 @@ export const FullBleed: Story = {
109109
<Card>
110110
<VStack gap={3}>
111111
<Text type="label">Normal divider</Text>
112-
<Text type="body">
113-
The divider respects container padding.
114-
</Text>
112+
<Text type="body">The divider respects container padding.</Text>
115113
<Divider />
116114
<Text type="body">Content below the divider.</Text>
117115
</VStack>
118116
</Card>
119117
<Card>
120118
<VStack gap={3}>
121119
<Text type="label">Full bleed divider</Text>
122-
<Text type="body">
123-
The divider extends to container edges.
124-
</Text>
120+
<Text type="body">The divider extends to container edges.</Text>
125121
<Divider isFullBleed />
126122
<Text type="body">Content below the divider.</Text>
127123
</VStack>
@@ -187,6 +183,28 @@ export const InCard: Story = {
187183
),
188184
};
189185

186+
export const NumericLabel: Story = {
187+
render: () => (
188+
<Section variant="muted">
189+
<div {...stylex.props(styles.storyWrapper)}>
190+
<Card>
191+
<VStack gap={3}>
192+
<Text type="supporting">Horizontal numeric label</Text>
193+
<Divider label={0} />
194+
</VStack>
195+
</Card>
196+
<Card height={200}>
197+
<HStack gap={4} xstyle={styles.fullHeight}>
198+
<Text type="body">Start</Text>
199+
<Divider orientation="vertical" label={0} />
200+
<Text type="body">End</Text>
201+
</HStack>
202+
</Card>
203+
</div>
204+
</Section>
205+
),
206+
};
207+
190208
export const FullBleedVertical: Story = {
191209
render: () => (
192210
<Section variant="muted">

‎packages/core/src/Chat/ChatSystemMessage.test.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@ describe('ChatSystemMessage', () => {
152152
expect(root).toContainElement(screen.getByRole('separator'));
153153
});
154154

155-
it('records Divider numeric-zero output for the shared FR15 advisory', () => {
155+
it('keeps the numeric-zero label visible and names the shared divider', () => {
156156
render(
157157
<ChatSystemMessage variant="divider" data-testid="divider-zero">
158158
{0}
159159
</ChatSystemMessage>,
160160
);
161161
const root = screen.getByTestId('divider-zero');
162162
const separator = screen.getByRole('separator');
163-
expect(root).toHaveTextContent('00');
164-
expect(separator).not.toHaveAccessibleName();
165-
expect(separator).not.toHaveAttribute('aria-labelledby');
163+
expect(root).toHaveTextContent('0');
164+
expect(separator).toHaveAccessibleName('0');
165+
expect(separator).toHaveAttribute('aria-labelledby');
166166
});
167167
});

‎packages/core/src/Divider/Divider.doc.mjs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export const docs = {
4040
{
4141
name: 'label',
4242
type: 'ReactNode',
43-
description: 'Optional label centered on the divider.',
43+
description:
44+
'Optional label centered on the divider. Numeric zero is preserved; null, booleans, and empty strings render no label.',
4445
},
4546
{
4647
name: 'variant',
@@ -92,7 +93,8 @@ export const docsZh = {
9293
{
9394
name: 'label',
9495
type: 'ReactNode',
95-
description: '居中显示在分隔线上的可选标签。',
96+
description:
97+
'居中显示在分隔线上的可选标签。数字 0 会保留;null、布尔值和空字符串不渲染标签。',
9698
},
9799
{
98100
name: 'variant',
@@ -143,7 +145,7 @@ export const docsDense = {
143145
},
144146
propDescriptions: {
145147
orientation: 'divider orientation',
146-
label: 'optional centered label on divider',
148+
label: 'optional centered label; preserves 0; null/boolean/"" omit it',
147149
variant: 'visual weight of divider line',
148150
isFullBleed: 'extend to container edges w/ negative margins',
149151
xstyle: 'StyleX styles for layout; must be stylex.create() value',

0 commit comments

Comments
 (0)