An open source design system that's fully customizable and agent ready
TypeScript
fix(List): drop the divider after the last item with hasDividers (#6420)
홍규진298c094353d2
diff --git a/.changeset/list-item-last-divider.md b/.changeset/list-item-last-divider.mdnew file mode 100644index 0000000000..8845c52793--- /dev/null+++ b/.changeset/list-item-last-divider.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] `List` with `hasDividers` no longer draws a divider after the last `ListItem`. The last-item reset used the `borderBlockEnd` shorthand, which StyleX's default property-specificity mode drops silently, so it never reached the shipped CSS; it is now the `borderBlockEndWidth` longhand.++@kyu-rongdiff --git a/packages/core/src/List/ListItem.source-build.test.mjs b/packages/core/src/List/ListItem.source-build.test.mjsnew file mode 100644index 0000000000..ab8241a76c--- /dev/null+++ b/packages/core/src/List/ListItem.source-build.test.mjs@@ -0,0 +1,41 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ListItem.source-build.test.mjs+ * @input Uses Babel, the core StyleX build config, and ListItem source+ * @output Verifies the divider reset for the last item survives compilation+ * @position Regression test for the shipped ListItem stylesheet+ */++import fs from 'node:fs/promises';+import path from 'node:path';+import {fileURLToPath} from 'node:url';+import {transformAsync} from '@babel/core';+import {describe, expect, it} from 'vitest';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const CORE_ROOT = path.resolve(__dirname, '../..');+const LIST_ITEM_SOURCE = path.join(__dirname, 'ListItem.tsx');++async function compileListItemRules() {+ const source = await fs.readFile(LIST_ITEM_SOURCE, 'utf8');+ const result = await transformAsync(source, {+ babelrc: false,+ configFile: path.join(CORE_ROOT, 'babel.config.json'),+ filename: LIST_ITEM_SOURCE,+ });+ return (result?.metadata?.stylex ?? []).map(([, rule]) => rule.ltr);+}++describe('ListItem divider stylesheet', () => {+ it('emits a :last-child rule that removes the divider after the last item', async () => {+ const rules = await compileListItemRules();++ // The divider is the item's block-end border. StyleX's default+ // property-specificity mode silently drops a `borderBlockEnd` shorthand,+ // so the last-item reset must be a longhand to reach the shipped CSS.+ expect(rules).toContainEqual(+ expect.stringMatching(/:last-child\{border-bottom-width:0\}$/),+ );+ });+});diff --git a/packages/core/src/List/ListItem.tsx b/packages/core/src/List/ListItem.tsxindex 437aba5eb8..a3b56347ef 100644--- a/packages/core/src/List/ListItem.tsx+++ b/packages/core/src/List/ListItem.tsx@@ -128,8 +128,12 @@ const styles = stylex.create({borderBlockEndWidth: borderVars['--border-width'],borderBlockEndStyle: 'solid',borderBlockEndColor: colorVars['--color-border'],+ // A longhand, not the `borderBlockEnd` shorthand: StyleX's default+ // property-specificity mode drops border shorthands silently, so the+ // shorthand never reached the shipped CSS and the last item kept its+ // divider.':last-child': {- borderBlockEnd: 'none',+ borderBlockEndWidth: 0,},},});