fix(web): show onboarding Industry dropdown above the wizard scrim
The Select dropdown is portaled to <body> with z-50, under the wizard's z-[9999] scrim, so it was invisible yet clickable through the scrim. Lift it to z-[10000] and cover the stacking order with a test (UF-007).
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { cleanup, render, screen } from '@testing-library/react';
|
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
import WhoAreYouStep from './WhoAreYouStep';
|
import WhoAreYouStep from './WhoAreYouStep';
|
||||||
import type { OnboardingProfileFields } from './types';
|
import type { OnboardingProfileFields } from './types';
|
||||||
@@ -50,4 +50,27 @@ describe('WhoAreYouStep', () => {
|
|||||||
expect(chip).toHaveClass('border-[var(--line-affordance)]');
|
expect(chip).toHaveClass('border-[var(--line-affordance)]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('stacks the Industry dropdown above the onboarding scrim', async () => {
|
||||||
|
// The wizard scrim (.onboarding-scrim in OnboardingWizard.tsx) is z-[9999].
|
||||||
|
// The dropdown is portaled to <body>, so it must carry a higher z-index or
|
||||||
|
// it renders under the scrim while still receiving clicks.
|
||||||
|
const ONBOARDING_SCRIM_Z = 9999;
|
||||||
|
// jsdom has no scrollIntoView; Radix Select calls it on the focused option.
|
||||||
|
Element.prototype.scrollIntoView ??= vi.fn();
|
||||||
|
render(
|
||||||
|
<WhoAreYouStep
|
||||||
|
profile={{ ...profile, industry: '' }}
|
||||||
|
onChange={vi.fn()}
|
||||||
|
onContinue={vi.fn()}
|
||||||
|
saving={false}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
fireEvent.keyDown(screen.getByRole('combobox', { name: 'Industry' }), { key: 'Enter' });
|
||||||
|
const listbox = await screen.findByRole('listbox');
|
||||||
|
|
||||||
|
const zClass = listbox.className.match(/(?:^|\s)z-\[?(\d+)\]?(?=\s|$)/);
|
||||||
|
expect(Number(zClass?.[1])).toBeGreaterThan(ONBOARDING_SCRIM_Z);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ const WhoAreYouStep = ({ profile, onChange, onContinue, saving }: WhoAreYouStepP
|
|||||||
>
|
>
|
||||||
<SelectValue placeholder="Select…" />
|
<SelectValue placeholder="Select…" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
{/* The dropdown is portaled to <body> with the primitive's z-50,
|
||||||
|
which put it under the wizard's z-[9999] scrim: invisible, yet
|
||||||
|
clickable through the scrim. Lift it above the scrim. */}
|
||||||
|
<SelectContent className="z-[10000]">
|
||||||
{INDUSTRIES.map(i => (
|
{INDUSTRIES.map(i => (
|
||||||
<SelectItem key={i} value={i}>{i}</SelectItem>
|
<SelectItem key={i} value={i}>{i}</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user