fix(time-picker): improve layout stability, a11y, and separator styling

- Change input group horizontal padding from px-3 to pl-3 pr-2 to
  better accommodate the trigger button.
- Add shrink-0 to the trigger button so it does not collapse in flex
  layouts.
- Mark the Clock icon with aria-hidden to keep it out of the
  accessibility tree.
- Forward the className prop in TimePickerSeparator and apply default
  muted-foreground text styling.
This commit is contained in:
2026-04-15 18:21:09 -04:00
parent 8d7948298b
commit 29bf4d2200

View File

@@ -723,7 +723,7 @@ function TimePickerInputGroup(props: DivProps) {
data-invalid={invalid ? "" : undefined} data-invalid={invalid ? "" : undefined}
{...inputGroupProps} {...inputGroupProps}
className={cn( className={cn(
"flex h-10 w-full cursor-text items-center gap-0.5 rounded-md border border-input bg-background px-3 py-2 shadow-xs outline-none transition-shadow", "flex h-10 w-full cursor-text items-center gap-0.5 rounded-md border border-input bg-background pl-3 pr-2 py-2 shadow-xs outline-none transition-shadow",
"has-[input:focus]:border-ring has-[input:focus]:ring-[3px] has-[input:focus]:ring-ring/50", "has-[input:focus]:border-ring has-[input:focus]:ring-[3px] has-[input:focus]:ring-ring/50",
invalid && "border-destructive ring-destructive/20", invalid && "border-destructive ring-destructive/20",
disabled && "cursor-not-allowed opacity-50", disabled && "cursor-not-allowed opacity-50",
@@ -1468,11 +1468,11 @@ function TimePickerTrigger(props: ButtonProps) {
ref={composedRef} ref={composedRef}
{...triggerProps} {...triggerProps}
className={cn( className={cn(
"ml-auto size-7 text-muted-foreground hover:text-foreground", "ml-auto size-7 shrink-0 text-muted-foreground hover:text-foreground",
className, className,
)} )}
> >
{children ?? <Clock className="size-4" />} {children ?? <Clock aria-hidden="true" className="size-4" />}
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
); );
@@ -2149,7 +2149,7 @@ interface TimePickerSeparatorProps extends React.ComponentProps<"span"> {
} }
function TimePickerSeparator(props: TimePickerSeparatorProps) { function TimePickerSeparator(props: TimePickerSeparatorProps) {
const { asChild, children, ...separatorProps } = props; const { asChild, children, className, ...separatorProps } = props;
const SeparatorPrimitive = asChild ? SlotPrimitive.Slot : "span"; const SeparatorPrimitive = asChild ? SlotPrimitive.Slot : "span";
@@ -2157,6 +2157,7 @@ function TimePickerSeparator(props: TimePickerSeparatorProps) {
<SeparatorPrimitive <SeparatorPrimitive
aria-hidden="true" aria-hidden="true"
data-slot="time-picker-separator" data-slot="time-picker-separator"
className={cn("text-sm text-muted-foreground", className)}
{...separatorProps} {...separatorProps}
> >
{children ?? ":"} {children ?? ":"}