Skip to content

Commit de7d26f

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(emcn): preserve editable combobox overlay text visibility
1 parent faa970e commit de7d26f

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎packages/emcn/src/components/combobox/combobox.dom.test.tsx‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* that it does, in both directions.
1111
*/
1212
import { act, type ReactNode, useState } from 'react'
13+
import { ChipCombobox } from '@sim/emcn'
1314
import { createRoot, type Root } from 'react-dom/client'
1415
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1516
import { InsideModalContext } from '../modal/modal'
@@ -92,6 +93,27 @@ describe('Combobox onOpenChange', () => {
9293
expect(control.classList.contains('pr-10')).toBe(false)
9394
})
9495

96+
it.each(['label', 'icon', 'none'] as const)(
97+
'preserves editable chip text visibility with %s overlay',
98+
(overlay) => {
99+
render(
100+
<ChipCombobox
101+
options={
102+
overlay === 'icon' ? [{ label: 'Alpha', value: 'alpha', icon: () => <svg /> }] : OPTIONS
103+
}
104+
editable
105+
value='alpha'
106+
overlayContent={overlay === 'label' ? <span>Formatted Alpha</span> : undefined}
107+
inputProps={{ className: 'text-[var(--text-primary)]' }}
108+
/>
109+
)
110+
111+
const control = trigger()
112+
expect(control.classList.contains('text-transparent')).toBe(overlay !== 'none')
113+
expect(control.classList.contains('text-[var(--text-primary)]')).toBe(overlay === 'none')
114+
}
115+
)
116+
95117
it.each([false, true])(
96118
'puts the field name and validation ARIA on the interactive control (editable=%s)',
97119
(editable) => {

‎packages/emcn/src/components/combobox/combobox.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,11 @@ const Combobox = memo(
800800
{...inputProps}
801801
className={cn(
802802
'w-full pr-10 transition-colors',
803-
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground',
804803
SelectedIcon && !overlayContent && 'pl-7',
805804
open && 'focus-visible:border-[var(--border-1)]',
806805
className,
807-
inputProps?.className
806+
inputProps?.className,
807+
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground'
808808
)}
809809
role='combobox'
810810
aria-expanded={open}

0 commit comments

Comments
 (0)