Skip to content
Merged
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
5 changes: 5 additions & 0 deletions src/core/app-switcher/__tests__/app-switcher.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ test('the menu is visible when the trigger button is clicked', () => {
fireEvent.click(button)
expect(screen.getByRole('menu')).toBeVisible()
})

test('additional props are forwarded to the trigger button', () => {
render(<AppSwitcherStories.Example data-testid="test-id" />)
expect(screen.getByTestId('test-id')).toBe(screen.getByRole('button'))
})
9 changes: 5 additions & 4 deletions src/core/app-switcher/app-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { getDisplayableProductsForExploreGroup } from './get-displayable-product
import { Menu } from '#src/core/menu'
import { useId } from 'react'

import type { ReactNode } from 'react'
import type { ButtonHTMLAttributes, ReactNode } from 'react'

interface AppSwitcherProps {
interface AppSwitcherProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/**
* The menu groups and their items. Should typically be `AppSwitcher.ExploreMenuGroup`,
* `AppSwitcher.YourAppsMenuGroup`, and `AppSwitcher.ProductMenuItem` components */
Expand All @@ -23,13 +23,14 @@ interface AppSwitcherProps {
* the products the current user has access to (in the Your Apps group), and other apps from Reapit (in the
* Explore group).
*/
export function AppSwitcher({ children }: AppSwitcherProps) {
const triggerId = useId()
export function AppSwitcher({ children, id, ...rest }: AppSwitcherProps) {
const triggerId = id ?? useId()
const menuId = useId()

return (
<>
<AppSwitcherNavIconButton
{...rest}
{...Menu.getTriggerProps({ id: triggerId, popoverTarget: menuId, popoverTargetAction: 'toggle' })}
/>
<Menu aria-labelledby={triggerId} id={menuId} placement="bottom-start">
Expand Down
2 changes: 1 addition & 1 deletion src/storybook/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Beta versions should be relatively stable but subject to occssional breaking cha

### **5.0.0-beta.44 - ??/??/25**

- TBC
- **fix:** App Switcher now accepts standard button attributes and fowards them to the underlying trigger button.

### **5.0.0-beta.43 - 12/08/25**

Expand Down
Loading