-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(react-button): do not expose default menuIcon in useMenuButtonBase_unstable #36345
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
Open
mainframev
wants to merge
4
commits into
microsoft:master
Choose a base branch
from
mainframev:fix/menu-button-base-default-icon
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−11
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
019c761
fix(react-button): do not expose default menuIcon in useMenuButtonBas…
mainframev 9b1f3bf
test(react-button): assert default menuIcon renders an svg instead of…
mainframev fb0e40d
fix(react-button): render base menuIcon slot only when provided
mainframev e0ceb23
test(react-button): assert default menuIcon svg via single component …
mainframev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-button-de57007e-ed5d-4006-b38f-0715f6088ed4.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "fix: do not expose default icon in base hook", | ||
| "packageName": "@fluentui/react-button", | ||
| "email": "vgenaev@gmail.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import * as React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
| import { renderHook } from '@testing-library/react-hooks'; | ||
| import '@testing-library/jest-dom'; | ||
| import { ButtonContextProvider } from '../../contexts/ButtonContext'; | ||
| import type { ButtonContextValue } from '../../contexts/ButtonContext'; | ||
| import { useMenuButton_unstable } from './useMenuButton'; | ||
| import { MenuButton } from './MenuButton'; | ||
|
|
||
| const wrap = (contextValue: ButtonContextValue = {}): React.FC<{ children?: React.ReactNode }> => { | ||
| const Wrapper: React.FC<{ children?: React.ReactNode }> = ({ children }) => ( | ||
|
|
@@ -19,10 +21,9 @@ describe('useMenuButton_unstable', () => { | |
| expect(result.current.components).toEqual({ root: 'button', icon: 'span', menuIcon: 'span' }); | ||
| }); | ||
|
|
||
| it('renders a menuIcon slot with a default chevron icon', () => { | ||
| const { result } = renderHook(() => useMenuButton_unstable({}, React.createRef())); | ||
| expect(result.current.menuIcon).toBeDefined(); | ||
| expect(React.isValidElement(result.current.menuIcon?.children)).toBe(true); | ||
| it('renders a menuIcon slot with a default icon', () => { | ||
| const result = render(<MenuButton />); | ||
| expect(result.container.querySelector('svg')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('preserves a user-provided menuIcon over the default chevron', () => { | ||
|
|
@@ -33,6 +34,16 @@ describe('useMenuButton_unstable', () => { | |
| expect(result.current.menuIcon?.children).toBe(customIcon); | ||
| }); | ||
|
|
||
| it('renders the default chevron when menuIcon is explicitly undefined', () => { | ||
| const result = render(<MenuButton menuIcon={undefined} />); | ||
| expect(result.container.querySelector('svg')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('hides the menuIcon slot when menuIcon is null', () => { | ||
| const { result } = renderHook(() => useMenuButton_unstable({ menuIcon: null }, React.createRef())); | ||
|
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. could we also check the edge-case if
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. added a test asserting it |
||
| expect(result.current.menuIcon).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('defaults aria-expanded to false when not provided', () => { | ||
| const { result } = renderHook(() => useMenuButton_unstable({}, React.createRef())); | ||
| expect(result.current.root['aria-expanded']).toBe(false); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
vr-tests-react-components/Positioning 2 screenshots
vr-tests-react-components/ProgressBar converged 1 screenshots
vr-tests-react-components/TagPicker 3 screenshots
There were 3 duplicate changes discarded. Check the build logs for more information.