-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(react-breadcrumb): make BreadcrumbButtonBaseProps distribute over the ARIA button union #36663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
7f171a4
adfef67
fe946b5
6c355b2
7a8947f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "fix: make BreadcrumbButtonBaseProps distribute over the ARIA button union so the anchor arm's href stays assignable", | ||
| "packageName": "@fluentui/react-breadcrumb", | ||
| "email": "array.knight@gmail.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import * as React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
| import { BreadcrumbButton } from './BreadcrumbButton'; | ||
| import type { BreadcrumbButtonProps } from './BreadcrumbButton.types'; | ||
| import type { BreadcrumbButtonBaseProps, BreadcrumbButtonProps } from './BreadcrumbButton.types'; | ||
| import { isConformant } from '../../testing/isConformant'; | ||
| import { breadcrumbButtonClassNames } from './useBreadcrumbButtonStyles.styles'; | ||
| import { ArrowRight16Filled } from '@fluentui/react-icons'; | ||
|
|
@@ -67,4 +67,20 @@ describe('BreadcrumbButton', () => { | |
| </div> | ||
| `); | ||
| }); | ||
|
|
||
| // Type-level regression test for https://github.com/microsoft/fluentui/issues/36645. | ||
| // `BreadcrumbButtonBaseProps` used a plain `Omit`, which collapsed the distributive ARIA button | ||
| // union and dropped the anchor arm's `href`. These assignments are validated by the package's | ||
| // type-check target. | ||
| it('keeps both arms of the ARIA button union assignable to BreadcrumbButtonBaseProps', () => { | ||
| const anchorProps: BreadcrumbButtonBaseProps = { as: 'a', href: '/somewhere' }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apologies for the confusion, but could we test the base hook with needed args, something like: it will cover both base hook and types, as we run typecheck against tests as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 6c355b2 — reworked to the renderHook shape. One adjustment from your sketch:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets clean up the unnecessary comments in tests and should be good to go. thank you! |
||
| const buttonProps: BreadcrumbButtonBaseProps = { as: 'button' }; | ||
|
|
||
| // @ts-expect-error - `size` is omitted from BreadcrumbButtonBaseProps | ||
| const sizeProps: BreadcrumbButtonBaseProps = { as: 'button', size: 'small' }; | ||
|
|
||
| expect(anchorProps).toBeDefined(); | ||
| expect(buttonProps).toBeDefined(); | ||
| expect(sizeProps).toBeDefined(); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.