Skip to content

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

TypeScript

fix(themes): keep the secondary ComplexSelector hover off an aria-disabled trigger (#7846)

Cindy Zhang06872b48bdae
diff --git a/.changeset/complexselector-theme-disabled-guard.md b/.changeset/complexselector-theme-disabled-guard.md
new file mode 100644
index 0000000000..a39578660b
--- /dev/null
+++ b/.changeset/complexselector-theme-disabled-guard.md
@@ -0,0 +1,10 @@
+---
+'@astryxdesign/theme-butter': patch
+'@astryxdesign/theme-stone': patch
+'@astryxdesign/theme-y2k': patch
+'@astryxdesign/cli': patch
+---
+
+[fix] The butter, stone, and y2k themes keep the secondary hover fill off a disabled `ComplexSelector` trigger whether the trigger is natively disabled or exposes `aria-disabled="true"`, the focusable disabled form `spec:AST-085` gives every control (FR6: no hover affordance on a disabled control). Before, the guard only recognized a natively disabled trigger. The themes `astryx theme eject` copies carry the same guard.
+
+@cixzhang
diff --git a/packages/cli/assets/templates/themes/butter/butterTheme.ts b/packages/cli/assets/templates/themes/butter/butterTheme.ts
index 809d469071..1d91ea5f54 100644
--- a/packages/cli/assets/templates/themes/butter/butterTheme.ts
+++ b/packages/cli/assets/templates/themes/butter/butterTheme.ts
@@ -81,7 +81,8 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
@@ -89,7 +90,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
color: SECONDARY_BUTTON.color,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const butterTheme = defineTheme({
diff --git a/packages/cli/assets/templates/themes/stone/stoneTheme.ts b/packages/cli/assets/templates/themes/stone/stoneTheme.ts
index 26ed5651d1..6a299170a5 100644
--- a/packages/cli/assets/templates/themes/stone/stoneTheme.ts
+++ b/packages/cli/assets/templates/themes/stone/stoneTheme.ts
@@ -100,14 +100,16 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
borderWidth: SECONDARY_BUTTON.borderWidth,
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const stoneTheme = defineTheme({
diff --git a/packages/cli/assets/templates/themes/y2k/y2kTheme.ts b/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
index 27fda0969f..1994eedf70 100644
--- a/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
+++ b/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
@@ -76,7 +76,8 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
@@ -84,7 +85,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
color: SECONDARY_BUTTON.color,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const y2kTheme = defineTheme({
diff --git a/packages/themes/butter/src/butterTheme.test.ts b/packages/themes/butter/src/butterTheme.test.ts
index 0ed627d08c..86854111ae 100644
--- a/packages/themes/butter/src/butterTheme.test.ts
+++ b/packages/themes/butter/src/butterTheme.test.ts
@@ -23,3 +23,11 @@ describe('butter touch + narrow type pin', () => {
);
});
});
+
+describe('butter secondary ComplexSelector', () => {
+ it('keeps the hover fill off a disabled trigger in either form', () => {
+ expect(generateThemeCSS(butterTheme).component).toMatch(
+ /:hover:not\(:has\(> ?:is\(:disabled, ?\[aria-disabled="true"\]\)\)\)/,
+ );
+ });
+});
diff --git a/packages/themes/butter/src/butterTheme.ts b/packages/themes/butter/src/butterTheme.ts
index 809d469071..1d91ea5f54 100644
--- a/packages/themes/butter/src/butterTheme.ts
+++ b/packages/themes/butter/src/butterTheme.ts
@@ -81,7 +81,8 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
@@ -89,7 +90,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
color: SECONDARY_BUTTON.color,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const butterTheme = defineTheme({
diff --git a/packages/themes/stone/src/stoneTheme.test.ts b/packages/themes/stone/src/stoneTheme.test.ts
index feafc980f3..e5c681f3f9 100644
--- a/packages/themes/stone/src/stoneTheme.test.ts
+++ b/packages/themes/stone/src/stoneTheme.test.ts
@@ -23,3 +23,11 @@ describe('stone touch + narrow type pin', () => {
);
});
});
+
+describe('stone secondary ComplexSelector', () => {
+ it('keeps the hover fill off a disabled trigger in either form', () => {
+ expect(generateThemeCSS(stoneTheme).component).toMatch(
+ /:hover:not\(:has\(> ?:is\(:disabled, ?\[aria-disabled="true"\]\)\)\)/,
+ );
+ });
+});
diff --git a/packages/themes/stone/src/stoneTheme.ts b/packages/themes/stone/src/stoneTheme.ts
index 26ed5651d1..6a299170a5 100644
--- a/packages/themes/stone/src/stoneTheme.ts
+++ b/packages/themes/stone/src/stoneTheme.ts
@@ -100,14 +100,16 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
borderWidth: SECONDARY_BUTTON.borderWidth,
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const stoneTheme = defineTheme({
diff --git a/packages/themes/y2k/src/y2kTheme.test.ts b/packages/themes/y2k/src/y2kTheme.test.ts
new file mode 100644
index 0000000000..9b6c3d7f34
--- /dev/null
+++ b/packages/themes/y2k/src/y2kTheme.test.ts
@@ -0,0 +1,13 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, expect, it} from 'vitest';
+import {generateThemeCSS} from '@astryxdesign/core/theme';
+import {y2kTheme} from './y2kTheme';
+
+describe('y2k secondary ComplexSelector', () => {
+ it('keeps the hover fill off a disabled trigger in either form', () => {
+ expect(generateThemeCSS(y2kTheme).component).toMatch(
+ /:hover:not\(:has\(> ?:is\(:disabled, ?\[aria-disabled="true"\]\)\)\)/,
+ );
+ });
+});
diff --git a/packages/themes/y2k/src/y2kTheme.ts b/packages/themes/y2k/src/y2kTheme.ts
index 27fda0969f..1994eedf70 100644
--- a/packages/themes/y2k/src/y2kTheme.ts
+++ b/packages/themes/y2k/src/y2kTheme.ts
@@ -76,7 +76,8 @@ const SECONDARY_SELECTOR = {
/**
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
- * the hover kept off a disabled trigger, whose inner button is disabled.
+ * the hover kept off a disabled trigger, whose inner button is disabled
+ * (natively or, keeping its tab stop, with `aria-disabled`).
*/
const SECONDARY_COMPLEX_SELECTOR = {
backgroundColor: SECONDARY_BUTTON.backgroundColor,
@@ -84,7 +85,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
borderStyle: SECONDARY_BUTTON.borderStyle,
borderColor: SECONDARY_BUTTON.borderColor,
color: SECONDARY_BUTTON.color,
- ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
+ SECONDARY_BUTTON[':hover'],
} as const;
export const y2kTheme = defineTheme({
diff --git a/scripts/check-secondary-selector-parity.test.mjs b/scripts/check-secondary-selector-parity.test.mjs
index 69682095a7..a95256d3d3 100644
--- a/scripts/check-secondary-selector-parity.test.mjs
+++ b/scripts/check-secondary-selector-parity.test.mjs
@@ -49,7 +49,8 @@ const HOVER_SCOPES = {
':hover:not([data-disabled], [data-readonly], .astryx-input-group *)',
'multi-selector':
':hover:not([data-disabled], [data-readonly], .astryx-input-group *)',
- 'complex-selector': ':hover:not(:has(> :disabled))',
+ 'complex-selector':
+ ':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))',
};
const GROUPED_TARGETS = new Set(['selector', 'multi-selector']);