Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions packages/emcn/src/components/combobox/combobox.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* that it does, in both directions.
*/
import { act, type ReactNode, useState } from 'react'
import { ChipCombobox } from '@sim/emcn'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
Comment thread
BillLeoutsakosvl346 marked this conversation as resolved.
import { InsideModalContext } from '../modal/modal'
Expand Down Expand Up @@ -92,6 +93,27 @@ describe('Combobox onOpenChange', () => {
expect(control.classList.contains('pr-10')).toBe(false)
})

it.each(['label', 'icon', 'none'] as const)(
'preserves editable chip text visibility with %s overlay',
(overlay) => {
render(
<ChipCombobox
options={
overlay === 'icon' ? [{ label: 'Alpha', value: 'alpha', icon: () => <svg /> }] : OPTIONS
}
editable
value='alpha'
overlayContent={overlay === 'label' ? <span>Formatted Alpha</span> : undefined}
inputProps={{ className: 'text-[var(--text-primary)]' }}
/>
)

const control = trigger()
expect(control.classList.contains('text-transparent')).toBe(overlay !== 'none')
expect(control.classList.contains('text-[var(--text-primary)]')).toBe(overlay === 'none')
}
)

it.each([false, true])(
'puts the field name and validation ARIA on the interactive control (editable=%s)',
(editable) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/emcn/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,11 @@ const Combobox = memo(
{...inputProps}
className={cn(
'w-full pr-10 transition-colors',
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground',
SelectedIcon && !overlayContent && 'pl-7',
open && 'focus-visible:border-[var(--border-1)]',
className,
inputProps?.className
inputProps?.className,
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground'
)}
role='combobox'
aria-expanded={open}
Expand Down
Loading