fix(account-dropdown): keep menu open when switching theme

This commit is contained in:
yyh
2026-03-03 21:00:00 +08:00
parent 65bf632ec0
commit a65735ff46
2 changed files with 15 additions and 1 deletions

View File

@@ -29,6 +29,10 @@ vi.mock('@/app/components/header/github-star', () => ({
default: () => <div data-testid="github-star">GithubStar</div>,
}))
vi.mock('@/app/components/base/theme-switcher', () => ({
default: () => <button type="button" data-testid="theme-switcher-button">Theme switcher</button>,
}))
vi.mock('@/context/app-context', () => ({
useAppContext: vi.fn(),
}))
@@ -276,6 +280,16 @@ describe('AccountDropdown', () => {
// Assert
expect(screen.queryByTestId('account-about')).not.toBeInTheDocument()
})
it('should keep account dropdown open when clicking the theme switcher', () => {
// Act
renderWithRouter(<AppSelector />)
fireEvent.click(screen.getByRole('button', { name: 'common.account.account' }))
fireEvent.click(screen.getByTestId('theme-switcher-button'))
// Assert
expect(screen.getByText('common.userProfile.logout')).toBeInTheDocument()
})
})
describe('Branding and Environment', () => {

View File

@@ -228,8 +228,8 @@ export default function AppSelector() {
)}
<AccountMenuSection>
<DropdownMenuItem
closeOnClick={false}
className="cursor-default data-[highlighted]:bg-transparent"
onSelect={e => e.preventDefault()}
>
<MenuItemContent
iconClassName="i-ri-t-shirt-2-line"