Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
c6d7fe7
chore(registry): update generated registry metadata
carllosnc Nov 18, 2026
7aa0827
fix(AnimateNumber): expose full value via aria-label for screen readers
carllosnc Nov 18, 2026
c23e5fb
fix(Avatar): default img alt attribute to empty string when omitted
carllosnc Nov 18, 2026
3f8d15e
fix(Breadcrumb): set aria-current=page on active breadcrumb item
carllosnc Nov 18, 2026
0810f76
fix(Button): forward aria-disabled and aria-busy when using asChild
carllosnc Nov 18, 2026
1a8e22d
fix(ButtonGroup): add role=group, forwardRef, type=button, and aria-p…
carllosnc Nov 18, 2026
07516fa
fix(Checkbox): use useId for unique IDs and wire aria-describedby
carllosnc Nov 18, 2026
9f41018
test(Checkbox): update auto-generated ID assertion for useId
carllosnc Nov 18, 2026
7d9666d
fix(Chip): avoid invalid nested button role and expose aria-pressed
carllosnc Nov 18, 2026
e14ac6e
fix(CircularProgress): clamp progress value to 0-100 range
carllosnc Nov 18, 2026
f246cde
fix(Combobox): highlight activeIndex option, link description, and hi…
carllosnc Nov 18, 2026
35857df
fix(Combobox): close listbox on Tab key press
carllosnc Nov 18, 2026
55246ac
fix(CommandPalette): add focus-within ring on input and tabIndex=-1 o…
carllosnc Nov 18, 2026
a618f5e
fix(DateField): add segment aria-labels, group role, and error/descri…
carllosnc Nov 18, 2026
ce1ef7e
fix(DatePicker): associate label/description and add full date aria-l…
carllosnc Nov 18, 2026
2fb8204
fix(DatePicker): close calendar on Escape and restore focus to trigger
carllosnc Nov 18, 2026
476d90f
fix(Dock): add aria-label on DockItem and Escape dismissal for tooltip
carllosnc Nov 18, 2026
a5bd52e
fix(Drawer): move close button inside dialog focus trap and clean unu…
carllosnc Nov 18, 2026
cb71e7d
fix(Dropdown): add menu role and arrow/Home/End/Tab keyboard navigation
carllosnc Nov 18, 2026
c857ad2
fix(Dropdown): add menuitem role and focus-visible styling
carllosnc Nov 18, 2026
70aaf9e
fix(Dropdown): add separator role on DropdownSeparator
carllosnc Nov 18, 2026
4d01c45
fix(Dropdown): pass aria-expanded and aria-haspopup=menu on trigger
carllosnc Nov 18, 2026
292f042
test(Dropdown): assert aria-haspopup=menu on trigger
carllosnc Nov 18, 2026
d706616
fix(FileUpload): replace undefined destructive token and wire dropzon…
carllosnc Nov 18, 2026
25e501e
fix(FloatActionMenu): add dialog/trigger ARIA attributes and close bu…
carllosnc Nov 18, 2026
350e21c
fix(IconButton): replace inner div with span and handle disabled link…
carllosnc Nov 18, 2026
fb3830b
fix(ImageExpander): add keyboard trigger support and dialog focus trap
carllosnc Nov 18, 2026
283e2c0
test(ImageExpander): query close button by accessible name
carllosnc Nov 18, 2026
1c12cc3
fix(ListTile): add aria-disabled and focus-visible ring on interactiv…
carllosnc Nov 18, 2026
2a13d0c
fix(Navbar): add default aria-label on nav landmark
carllosnc Nov 18, 2026
5b9ee29
fix(NavigationMenu): add default aria-label on nav landmark
carllosnc Nov 18, 2026
966f6ca
fix(Pagination): add focus-visible ring color and remove duplicate di…
carllosnc Nov 18, 2026
f8b65d4
fix(PieChart): anchor tooltip container to SVG wrapper and refine offset
carllosnc Nov 18, 2026
2818cb9
fix(PieChart): position tooltip at slice centroid on legend hover
carllosnc Nov 18, 2026
92405fb
fix(Popover): add role=dialog on PopoverContent
carllosnc Nov 18, 2026
bcaa3fc
fix(Popover): pass aria-expanded and aria-haspopup=dialog on trigger
carllosnc Nov 18, 2026
a1d0513
fix(ProgressBar): link visible label via aria-labelledby
carllosnc Nov 18, 2026
2882937
fix(ProgressBar): guard against non-positive max value
carllosnc Nov 18, 2026
f3e4a45
fix(Radio): use named forwardRef and wire description via aria-descri…
carllosnc Nov 18, 2026
f8448b6
fix(Radio): use useId for unique radio IDs
carllosnc Nov 18, 2026
b33f6a3
test(Radio): update auto-generated ID assertion for useId
carllosnc Nov 18, 2026
f8730cd
fix(ScrollArea): make scrollable viewport keyboard-focusable
carllosnc Nov 18, 2026
8ffd179
fix(Select): wire label htmlFor and add focus-visible styling on options
carllosnc Nov 18, 2026
d8516d0
fix(Sidebar): add mobile drawer focus trap and fix SidebarSection sem…
carllosnc Nov 18, 2026
89680e7
fix(Slider): use named forwardRef and wire description via aria-descr…
carllosnc Nov 18, 2026
79f422a
fix(Slider): use useId for unique IDs and guard min===max division
carllosnc Nov 18, 2026
84a08a0
fix(Spinner): add role=status and default aria-label
carllosnc Nov 18, 2026
5799afd
fix(StatsCard): hide decorative SVG/icons and guard single-point spar…
carllosnc Nov 18, 2026
d9dc210
fix(Stepper): add keyboard activation and aria-current=step
carllosnc Nov 18, 2026
d2c1c21
fix(Switch): add role=switch and wire description via aria-describedby
carllosnc Nov 18, 2026
02fdc33
fix(Switch): use useId for unique switch IDs
carllosnc Nov 18, 2026
cd68ecc
test(Switch): assert switch role and unique useId association
carllosnc Nov 18, 2026
eb980a3
fix(SystemLogs): add log role, keyboard-focusable scroll area, and ar…
carllosnc Nov 18, 2026
3f2bde2
fix(Table): make TableContainer keyboard-scrollable and default Table…
carllosnc Nov 18, 2026
f0795e9
fix(Tabs): replace Math.random ID with React.useId
carllosnc Nov 18, 2026
baf51f9
fix(TagInput): replace undefined destructive token, add remove focus …
carllosnc Nov 18, 2026
ca878f0
fix(Textarea): use named forwardRef and add role=alert on error
carllosnc Nov 18, 2026
f89480f
fix(Textarea): use useId for unique textarea IDs
carllosnc Nov 18, 2026
b66f69b
fix(Tooltip): dismiss open tooltip on Escape key
carllosnc Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions public/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"ButtonGroupItem"
],
"propsDefinitions": [
"export interface ButtonGroupProps {\r\n children: ReactNode;\r\n className?: string;\r\n /** @default false */\r\n vertical?: boolean;\r\n}\r\n\r\n/**\r\n * Compound segmented button container (`children` with `ButtonGroupItem`).\r\n *\r\n * @example\r\n * ```tsx\r\n * <ButtonGroup>\r\n * <ButtonGroupItem active>Day</ButtonGroupItem>\r\n * <ButtonGroupItem>Week</ButtonGroupItem>\r\n * </ButtonGroup>\r\n * ```\r\n */",
"export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {\r\n children: ReactNode;\r\n className?: string;\r\n /** @default false */\r\n vertical?: boolean;\r\n}\r\n\r\n/**\r\n * Compound segmented button container (`children` with `ButtonGroupItem`).\r\n *\r\n * @example\r\n * ```tsx\r\n * <ButtonGroup>\r\n * <ButtonGroupItem selected>Day</ButtonGroupItem>\r\n * <ButtonGroupItem>Week</ButtonGroupItem>\r\n * </ButtonGroup>\r\n * ```\r\n */",
"export interface ButtonGroupItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {\r\n /** @default false */\r\n selected?: boolean;\r\n}"
]
},
Expand Down Expand Up @@ -535,7 +535,7 @@
"useDateField"
],
"propsDefinitions": [
"export interface DateFieldProps {\r\n label?: string;\r\n description?: string;\r\n error?: string;\r\n value?: Date | null;\r\n onChange?: (date: Date | null) => void;\r\n className?: string;\r\n disabled?: boolean;\r\n isRequired?: boolean;\r\n}\r\n\r\ninterface SegmentProps {\r\n value: string;\r\n placeholder: string;\r\n max: number;\r\n onUpdate: (val: string) => void;\r\n onNext: () => void;\r\n onPrev: () => void;\r\n disabled?: boolean;\r\n}",
"export interface DateFieldProps {\r\n label?: string;\r\n description?: string;\r\n error?: string;\r\n value?: Date | null;\r\n onChange?: (date: Date | null) => void;\r\n className?: string;\r\n disabled?: boolean;\r\n isRequired?: boolean;\r\n}\r\n\r\ninterface SegmentProps {\r\n value: string;\r\n placeholder: string;\r\n ariaLabel: string;\r\n ariaInvalid?: boolean;\r\n max: number;\r\n onUpdate: (val: string) => void;\r\n onNext: () => void;\r\n onPrev: () => void;\r\n disabled?: boolean;\r\n}",
"export interface UseDateFieldProps {\n value?: Date | null;\n onChange?: (date: Date | null) => void;\n}"
]
},
Expand Down Expand Up @@ -1166,7 +1166,7 @@
],
"propsDefinitions": [
"export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {\r\n label?: string;\r\n description?: string;\r\n}\r\n\r\n/**\r\n * Accessible radio input with optional `label` and `description` props.\r\n *\r\n * @example\r\n * ```tsx\r\n * <Radio name=\"plan\" label=\"Pro Plan\" value=\"pro\" checked={plan === 'pro'} onChange={() => setPlan('pro')} />\r\n * ```\r\n */",
"export interface UseRadioProps {\n id?: string;\n label?: string;\n}"
"export interface UseRadioProps {\n id?: string;\n}"
]
},
"radio-card": {
Expand Down Expand Up @@ -1344,7 +1344,7 @@
],
"propsDefinitions": [
"export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange' | 'value' | 'defaultValue'> {\r\n label?: string;\r\n description?: string;\r\n value?: number;\r\n defaultValue?: number;\r\n onChange?: (value: number) => void;\r\n /** @default false */\r\n showValue?: boolean;\r\n}\r\n\r\n/**\r\n * Prop-driven (`value`, `onChange`, `min`, `max`) range slider input.\r\n *\r\n * @example\r\n * ```tsx\r\n * <Slider label=\"Volume\" min={0} max={100} value={volume} onChange={setVolume} />\r\n * ```\r\n */",
"export interface UseSliderProps {\n id?: string;\n label?: string;\n min?: string | number;\n max?: string | number;\n value?: string | number;\n defaultValue?: string | number;\n onChange?: (value: number) => void;\n}"
"export interface UseSliderProps {\n id?: string;\n min?: string | number;\n max?: string | number;\n value?: string | number;\n defaultValue?: string | number;\n onChange?: (value: number) => void;\n}"
]
},
"spinner": {
Expand Down Expand Up @@ -1469,7 +1469,7 @@
],
"propsDefinitions": [
"export interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {\r\n label?: string;\r\n description?: string;\r\n}\r\n\r\n/**\r\n * Accessible toggle switch with optional `label` and `description` props.\r\n *\r\n * @example\r\n * ```tsx\r\n * <Switch label=\"Email alerts\" checked={enabled} onChange={(e) => setEnabled(e.target.checked)} />\r\n * ```\r\n */",
"export interface UseSwitchProps {\n id?: string;\n label?: string;\n}"
"export interface UseSwitchProps {\n id?: string;\n}"
]
},
"systemlogs": {
Expand Down Expand Up @@ -1608,7 +1608,7 @@
],
"propsDefinitions": [
"export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\r\n label?: string;\r\n error?: string;\r\n helperText?: string;\r\n /** @default false */\r\n autoGrow?: boolean;\r\n}\r\n\r\n/**\r\n * Multi-line text input with optional `label`, `description`, and `error` props.\r\n *\r\n * @example\r\n * ```tsx\r\n * <Textarea label=\"Notes\" rows={4} placeholder=\"Write a summary...\" />\r\n * ```\r\n */",
"export interface UseTextareaProps {\n id?: string;\n label?: string;\n autoGrow?: boolean;\n value?: string | number | readonly string[];\n onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;\n}"
"export interface UseTextareaProps {\n id?: string;\n autoGrow?: boolean;\n value?: string | number | readonly string[];\n onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;\n}"
]
},
"toast": {
Expand Down
18 changes: 10 additions & 8 deletions src/dashkit/AnimateNumber/AnimateNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ export const AnimateNumber = forwardRef<HTMLSpanElement, AnimateNumberProps>(fun
const chars = fullString.split("");

return (
<span ref={ref} data-slot="animate-number" className={className} {...props}>
{chars.map((char, index) => (
<Digit
key={index}
char={char}
duration={duration}
/>
))}
<span ref={ref} data-slot="animate-number" aria-label={fullString} className={className} {...props}>
<span aria-hidden="true">
{chars.map((char, index) => (
<Digit
key={index}
char={char}
duration={duration}
/>
))}
</span>
</span>
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/dashkit/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>(
ref={imgRef}
key={src}
src={src}
alt={alt}
alt={alt ?? ''}
onLoad={() => setIsLoaded(true)}
onError={() => setHasError(true)}
initial={{ opacity: 0 }}
Expand Down
1 change: 1 addition & 0 deletions src/dashkit/Breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const BreadcrumbItem = React.forwardRef<HTMLLIElement, BreadcrumbItemProp
>
<Component
href={href}
aria-current={active ? 'page' : undefined}
className={cn(
'flex items-center gap-1.5 text-sm transition-colors',
href ? 'text-muted-foreground hover:text-foreground' : 'text-muted-foreground font-medium',
Expand Down
2 changes: 2 additions & 0 deletions src/dashkit/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(

return cloneElement(child as ReactElement<Record<string, unknown>>, {
ref,
'aria-disabled': disabled || loading || undefined,
'aria-busy': loading || undefined,
className: cn(classes, childProps.className),
children: (
<>
Expand Down
79 changes: 48 additions & 31 deletions src/dashkit/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode, type ButtonHTMLAttributes } from 'react';
import { forwardRef, type ReactNode, type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
import { cva } from 'class-variance-authority';
import { cn } from '../utils/cn';

Expand All @@ -17,7 +17,7 @@ const buttonGroupVariants = cva(
}
);

export interface ButtonGroupProps {
export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
children: ReactNode;
className?: string;
/** @default false */
Expand All @@ -30,45 +30,62 @@ export interface ButtonGroupProps {
* @example
* ```tsx
* <ButtonGroup>
* <ButtonGroupItem active>Day</ButtonGroupItem>
* <ButtonGroupItem selected>Day</ButtonGroupItem>
* <ButtonGroupItem>Week</ButtonGroupItem>
* </ButtonGroup>
* ```
*/
export function ButtonGroup({ children, className, vertical = false }: ButtonGroupProps) {
return (
<div className={cn(buttonGroupVariants({ vertical }), className)}>
{children}
</div>
);
}
export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
function ButtonGroup({ children, className, vertical = false, role = 'group', ...props }, ref) {
return (
<div
ref={ref}
role={role}
className={cn(buttonGroupVariants({ vertical }), className)}
{...props}
>
{children}
</div>
);
}
);

export interface ButtonGroupItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/** @default false */
selected?: boolean;
}

export function ButtonGroupItem({
children,
className,
selected = false,
...props
}: ButtonGroupItemProps) {
return (
<button
className={cn(
'ds-rounded relative inline-flex items-center justify-center font-medium text-sm h-9 px-4',
'bg-card text-foreground border border-border ds-border-width hover:bg-muted/60 transition-all cursor-pointer',
'focus:outline-none focus:z-10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.98]',
selected && 'bg-ds-200 text-foreground font-semibold z-10 shadow-xs dark:bg-ds-700 dark:text-foreground',
className
)}
{...props}
>
{children}
</button>
);
}
export const ButtonGroupItem = forwardRef<HTMLButtonElement, ButtonGroupItemProps>(
function ButtonGroupItem(
{
children,
className,
selected = false,
type = 'button',
...props
},
ref
) {
return (
<button
ref={ref}
type={type}
aria-pressed={selected}
className={cn(
'ds-rounded relative inline-flex items-center justify-center font-medium text-sm h-9 px-4',
'bg-card text-foreground border border-border ds-border-width hover:bg-muted/60 transition-all cursor-pointer',
'focus:outline-none focus:z-10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:scale-[0.98]',
'disabled:opacity-50 disabled:cursor-not-allowed',
selected && 'bg-ds-200 text-foreground font-semibold z-10 shadow-xs dark:bg-ds-700 dark:text-foreground',
className
)}
{...props}
>
{children}
</button>
);
}
);

ButtonGroup.displayName = 'ButtonGroup';
ButtonGroupItem.displayName = 'ButtonGroupItem';
6 changes: 3 additions & 3 deletions src/dashkit/Checkbox/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe('Checkbox', () => {
expect(visualBox).toBeInTheDocument();
});

it('generates an ID automatically from label if not provided', () => {
it('generates a unique ID automatically when not provided', () => {
render(<Checkbox label="My Awesome Checkbox" />);
const label = screen.getByText(/My Awesome Checkbox/i);
const input = screen.getByRole('checkbox');
expect(input.id).toBe('checkbox-my-awesome-checkbox');
expect(label.parentElement).toHaveAttribute('for', 'checkbox-my-awesome-checkbox');
expect(input.id).toBeTruthy();
expect(label.closest('label')).toHaveAttribute('for', input.id);
});

it('triggers onChange when clicked', () => {
Expand Down
25 changes: 15 additions & 10 deletions src/dashkit/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, type InputHTMLAttributes } from 'react';
import { forwardRef, useId, type InputHTMLAttributes } from 'react';
import { cn } from '../utils/cn';

export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'children'> {
Expand All @@ -16,7 +16,10 @@ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement
*/
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
function Checkbox({ label, description, className, id, ...props }, ref) {
const checkboxId = id || (label ? `checkbox-${label.toLowerCase().replace(/\s+/g, '-')}` : undefined);
const generatedId = useId();
const checkboxId = id || `checkbox-${generatedId}`;
const descriptionId = description ? `${checkboxId}-description` : undefined;
const describedBy = [props['aria-describedby'], descriptionId].filter(Boolean).join(' ') || undefined;

return (
<div className={cn('group flex gap-3 relative transition-all duration-200 items-center', className)}>
Expand All @@ -27,6 +30,7 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
type="checkbox"
id={checkboxId}
ref={ref}
aria-describedby={describedBy}
className="peer sr-only"
/>
<div
Expand All @@ -48,21 +52,22 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
</label>
</div>
{(label || description) && (
<label
htmlFor={checkboxId}
className="flex flex-col cursor-pointer select-none"
>
<div className="flex flex-col select-none">
{label && (
<span data-slot="label" className="text-sm font-medium text-foreground tracking-tight leading-5">
<label
htmlFor={checkboxId}
data-slot="label"
className="text-sm font-medium text-foreground tracking-tight leading-5 cursor-pointer"
>
{label}
</span>
</label>
)}
{description && (
<span data-slot="description" className="text-xs text-muted-foreground tracking-tight">
<span id={descriptionId} data-slot="description" className="text-xs text-muted-foreground tracking-tight">
{description}
</span>
)}
</label>
</div>
)}
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/dashkit/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ export const Chip = React.forwardRef<HTMLButtonElement | HTMLDivElement, ChipPro
<div
ref={ref as React.Ref<HTMLDivElement>}
data-slot="chip"
role={isInteractive ? 'button' : undefined}
role={isKeyboardActivatable ? 'button' : undefined}
tabIndex={isKeyboardActivatable ? 0 : undefined}
aria-pressed={isKeyboardActivatable ? selected : undefined}
aria-disabled={disabled || undefined}
onClick={isInteractive ? onClick : undefined}
onKeyDown={(e) => {
Expand Down
5 changes: 3 additions & 2 deletions src/dashkit/CircularProgress/CircularProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ export const CircularProgress = React.forwardRef<HTMLDivElement, CircularProgres
const dimension = typeof size === 'number' ? size : sizeMap[size];
const stroke = strokeWidth || (typeof size === 'number' ? Math.max(2, size / 10) : strokeWidthMap[size]);

const clampedValue = Math.min(Math.max(value, 0), 100);
const radius = (dimension - stroke) / 2;
const circumference = 2 * Math.PI * radius;
const offset = circumference - (value / 100) * circumference;
const offset = circumference - (clampedValue / 100) * circumference;

const trackClasses = trackColor || (variant === 'solid' ? 'text-ds-100 dark:text-ds-800' : softTrackColors[color]);

Expand All @@ -95,7 +96,7 @@ export const CircularProgress = React.forwardRef<HTMLDivElement, CircularProgres
ref={ref}
data-slot="circular-progress"
role="progressbar"
aria-valuenow={Math.round(value)}
aria-valuenow={Math.round(clampedValue)}
aria-valuemin={0}
aria-valuemax={100}
className={cn('relative inline-flex items-center justify-center', className)}
Expand Down
12 changes: 8 additions & 4 deletions src/dashkit/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function Combobox({

const inputId = useId();
const listId = useId();
const descriptionId = description ? `${inputId}-description` : undefined;
const activeOptionId =
isOpen && activeIndex >= 0 && activeIndex < filteredOptions.length
? `${listId}-option-${activeIndex}`
Expand Down Expand Up @@ -130,7 +131,7 @@ export function Combobox({

<div data-slot="wrapper" className="relative group" ref={inputWrapperRef}>
<div className="absolute left-3.5 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors duration-200 pointer-events-none group-focus-within:text-foreground">
<FiSearch className="size-4" />
<FiSearch className="size-4" aria-hidden="true" />
</div>

<input
Expand All @@ -143,6 +144,7 @@ export function Combobox({
aria-controls={isOpen ? listId : undefined}
aria-autocomplete="list"
aria-activedescendant={activeOptionId}
aria-describedby={descriptionId}
disabled={disabled}
value={query}
onChange={(e) => {
Expand All @@ -168,14 +170,14 @@ export function Combobox({
className="p-1.5 -m-0.5 rounded-full text-muted-foreground transition-all hover:text-foreground hover:bg-muted"
aria-label="Clear selection"
>
<FiX className="size-3.5" />
<FiX className="size-3.5" aria-hidden="true" />
</button>
)}
<div className={cn(
'text-muted-foreground transition-transform duration-300 pointer-events-none',
isOpen && 'rotate-180'
)}>
<FiChevronDown className="size-4" />
<FiChevronDown className="size-4" aria-hidden="true" />
</div>
</div>

Expand Down Expand Up @@ -205,6 +207,7 @@ export function Combobox({
) : (
filteredOptions.map((opt, index) => {
const isSelected = isOptionSelected(opt);
const isActive = index === activeIndex;
return (
<button
key={opt.value}
Expand All @@ -216,6 +219,7 @@ export function Combobox({
onClick={() => handleSelect(opt)}
className={cn(
'w-full px-4 py-2.5 text-sm text-left flex items-center justify-between duration-200 transition-colors ds-rounded hover:text-popover-fg hover:bg-popover-item',
isActive && !isSelected && 'bg-popover-item text-popover-fg',
isSelected && 'bg-popover-item-selected text-popover-item-selected-fg font-semibold hover:bg-popover-item-selected'
)}
>
Expand All @@ -234,7 +238,7 @@ export function Combobox({
</div>

{description && (
<span data-slot="helper" className="text-[12px] text-muted-foreground ml-1 tracking-tight">
<span id={descriptionId} data-slot="helper" className="text-[12px] text-muted-foreground ml-1 tracking-tight">
{description}
</span>
)}
Expand Down
5 changes: 5 additions & 0 deletions src/dashkit/Combobox/useCombobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export function useCombobox({
return;
}

if (e.key === 'Tab' && isOpen) {
setIsOpen(false);
return;
}

if (e.key === 'Enter' && isOpen && activeIndex >= 0 && activeIndex < count) {
e.preventDefault();
handleSelect(filteredOptions[activeIndex]);
Expand Down
Loading
Loading