An open source design system that's fully customizable and agent ready
TypeScript
feat(typeahead): themeable empty-state target (#4862)
freddymeta90260558f1f1
diff --git a/.changeset/typeahead-empty-state-target.md b/.changeset/typeahead-empty-state-target.mdnew file mode 100644index 0000000000..197ef02e3a--- /dev/null+++ b/.changeset/typeahead-empty-state-target.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[feat] Typeahead: expose the empty ("No results found") state as a themeable target (`astryx-typeahead-empty-state`), so themes can restyle it without relying on structural CSS selectors.++@freddymetadiff --git a/packages/core/src/Typeahead/BaseTypeahead.tsx b/packages/core/src/Typeahead/BaseTypeahead.tsxindex c8b0fecd4c..28f0901c44 100644--- a/packages/core/src/Typeahead/BaseTypeahead.tsx+++ b/packages/core/src/Typeahead/BaseTypeahead.tsx@@ -821,7 +821,11 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({stylex.props(styles.dropdown),)}>{results.length === 0 && hasSearched ? (- <div {...stylex.props(styles.emptyState)}>+ <div+ {...mergeProps(+ themeProps('typeahead-empty-state'),+ stylex.props(styles.emptyState),+ )}>{emptySearchResultsText}</div>) : (diff --git a/packages/core/src/Typeahead/Typeahead.doc.mjs b/packages/core/src/Typeahead/Typeahead.doc.mjsindex 1411879fc2..e3d8799588 100644--- a/packages/core/src/Typeahead/Typeahead.doc.mjs+++ b/packages/core/src/Typeahead/Typeahead.doc.mjs@@ -183,6 +183,7 @@ export const docs = {targets: [{className: 'astryx-typeahead', visualProps: ['status', 'size']},{className: 'astryx-typeahead-dropdown'},+ {className: 'astryx-typeahead-empty-state'},{className: 'astryx-typeahead-item'},],},diff --git a/packages/core/src/Typeahead/Typeahead.test.tsx b/packages/core/src/Typeahead/Typeahead.test.tsxindex 4b52bbe85c..6e53840e7c 100644--- a/packages/core/src/Typeahead/Typeahead.test.tsx+++ b/packages/core/src/Typeahead/Typeahead.test.tsx@@ -171,6 +171,28 @@ describe('BaseTypeahead', () => {});});+ it('exposes the empty state as a themeable target', async () => {+ const {container} = render(+ <BaseTypeahead+ searchSource={fruitSource}+ value={null}+ onChange={() => {}}+ debounceMs={0}+ emptySearchResultsText="No results found"+ />,+ );+ const input = screen.getByRole('combobox');+ fireEvent.change(input, {target: {value: 'zzzzz'}});++ await waitFor(() => {+ const emptyState = container.querySelector(+ '.astryx-typeahead-empty-state',+ );+ expect(emptyState).not.toBeNull();+ expect(emptyState).toHaveTextContent('No results found');+ });+ });+describe('empty results active descendant (#4059)', () => {it('does not set aria-activedescendant when search has 0 results', async () => {render(