feat(employee-hours): make business selector resizable
This commit is contained in:
parent
48fcd34608
commit
daa0abbf03
@ -35,6 +35,7 @@ let resultTotal: number | null = null
|
||||
let totals: EmployeeHoursRecordPage['totals']
|
||||
|
||||
beforeEach(() => {
|
||||
config.rules = []
|
||||
records = []
|
||||
employees = []
|
||||
resultTotal = null
|
||||
@ -114,6 +115,30 @@ describe('员工工时业务操作列', () => {
|
||||
expect(screen.getByRole('textbox', { name: '部门' })).toHaveValue('运营部')
|
||||
})
|
||||
|
||||
it('业务内容下拉框支持向下向右调整尺寸,并完整展示长选项', async () => {
|
||||
config.rules = [{
|
||||
id: 'rule-long',
|
||||
businessContent: '一条需要完整查看的业务内容名称,不应在下拉选项中被截断',
|
||||
businessCategory: '较长的业务分类说明',
|
||||
workFrequency: '每周',
|
||||
initiativeType: '主动',
|
||||
approvedScore: 1,
|
||||
sortOrder: 0,
|
||||
}]
|
||||
|
||||
render(<EmployeeHoursHoursView canEdit canDownload={false} />)
|
||||
await screen.findByText('暂无员工工时记录')
|
||||
fireEvent.click(screen.getByRole('button', { name: '新增员工工时' }))
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '新增员工工时' })
|
||||
fireEvent.focus(within(dialog).getByRole('combobox', { name: '业务内容' }))
|
||||
const listbox = await screen.findByRole('listbox', { name: '业务内容选项' })
|
||||
|
||||
expect(listbox).toHaveClass('resize', 'overflow-auto')
|
||||
expect(within(listbox).getByText('一条需要完整查看的业务内容名称,不应在下拉选项中被截断')).toHaveClass('whitespace-normal', 'break-words')
|
||||
expect(within(listbox).getByText('较长的业务分类说明')).toHaveClass('whitespace-normal', 'break-words')
|
||||
})
|
||||
|
||||
it('将操作列放在最左侧,并固定业务分类之前的四个字段', async () => {
|
||||
records = [record]
|
||||
render(<EmployeeHoursHoursView canEdit canDownload={false} />)
|
||||
|
||||
@ -276,7 +276,12 @@ function SearchableSelect({
|
||||
</button>
|
||||
</div>
|
||||
{open ? (
|
||||
<div id={listboxId} role="listbox" className="absolute z-30 mt-1 max-h-56 w-full min-w-[260px] overflow-y-auto rounded-[5px] border border-zinc-200 bg-white py-1 shadow-lg">
|
||||
<div
|
||||
id={listboxId}
|
||||
role="listbox"
|
||||
aria-label={`${ariaLabel}选项`}
|
||||
className="absolute z-30 mt-1 min-h-36 min-w-[260px] w-[min(100%,32rem)] max-h-[min(70vh,32rem)] max-w-[calc(100vw-2rem)] resize overflow-auto rounded-[5px] border border-zinc-200 bg-white py-1 shadow-lg"
|
||||
>
|
||||
{filteredOptions.map((option, index) => (
|
||||
<button
|
||||
id={`${listboxId}-${option.value}`}
|
||||
@ -290,8 +295,8 @@ function SearchableSelect({
|
||||
className={`flex w-full items-start gap-2 px-3 py-2 text-left ${index === currentActiveIndex ? 'bg-zinc-100' : 'bg-white'} hover:bg-zinc-100`}
|
||||
>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm text-zinc-800">{option.label}</span>
|
||||
{option.description ? <span className="mt-0.5 block truncate text-[11px] text-zinc-400">{option.description}</span> : null}
|
||||
<span className="block whitespace-normal break-words text-sm leading-5 text-zinc-800">{option.label}</span>
|
||||
{option.description ? <span className="mt-0.5 block whitespace-normal break-words text-[11px] leading-4 text-zinc-400">{option.description}</span> : null}
|
||||
</span>
|
||||
{option.value === value ? <Check size={14} className="mt-0.5 shrink-0 text-zinc-700" /> : null}
|
||||
</button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user