fix(react-button): do not expose default menuIcon in useMenuButtonBase_unstable#36345
Open
mainframev wants to merge 3 commits into
Open
fix(react-button): do not expose default menuIcon in useMenuButtonBase_unstable#36345mainframev wants to merge 3 commits into
mainframev wants to merge 3 commits into
Conversation
|
Pull request demo site: URL |
📊 Bundle size reportUnchanged fixtures
|
mainframev
added a commit
to mainframev/fluentui
that referenced
this pull request
Jun 24, 2026
…on_unstable Align with the standalone react-button PR (microsoft#36345). Replaces the post-hoc mutation of baseState.menuIcon with passing a null-safe default into useMenuButtonBase_unstable, so menuIcon={null} still hides the icon. This react-button change is owned by microsoft#36345 and will drop out of this branch once microsoft#36345 merges and this branch is rebased onto master.
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-react-components/Menu 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Menu.Nested Submenus Small Viewport Stacked.nested menu.chromium.png | 977 | Changed |
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png | 413 | Changed |
vr-tests-react-components/Positioning 2 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Positioning.Positioning end.chromium.png | 624 | Changed |
| vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png | 20 | Changed |
vr-tests-react-components/ProgressBar converged 2 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png | 25 | Changed |
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png | 155 | Changed |
vr-tests-react-components/TagPicker 3 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png | 658 | Changed |
| vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png | 1319 | Changed |
| vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png | 635 | Changed |
There were 3 duplicate changes discarded. Check the build logs for more information.
7b39038 to
bde5af0
Compare
dmytrokirpa
reviewed
Jun 25, 2026
| }); | ||
|
|
||
| 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.
could we also check the edge-case if undefined overrides the default icon as well
Contributor
Author
There was a problem hiding this comment.
added a test asserting it
| defaultProps: { | ||
| children: <ChevronDownRegular />, | ||
| }, | ||
| renderByDefault: true, |
Contributor
There was a problem hiding this comment.
should we render it by default even if it's empty?
Contributor
Author
There was a problem hiding this comment.
Good catch, updated
…e_unstable
Move the default ChevronDownRegular icon out of the headless base hook
(useMenuButtonBase_unstable) and into the styled useMenuButton_unstable so
that headless consumers do not inherit a default icon. The default is applied
in a null-safe way so that menuIcon={null} still hides the icon.
Add regression tests covering menuIcon={null} on the styled hook and the
absence of a default icon on the base hook.
… the specific icon
Align useMenuButtonBase_unstable with the renderByDefault convention used across v9 components (useField, useMenuItemBase): render the menuIcon slot only when a menuIcon is supplied instead of an empty span by default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
75d8fc1 to
fb0e40d
Compare
dmytrokirpa
reviewed
Jun 25, 2026
| expect(React.isValidElement(result.current.menuIcon?.children)).toBe(true); | ||
|
|
||
| const { container } = render(result.current.menuIcon?.children as React.ReactElement); | ||
| expect(container.querySelector('svg')).toBeInTheDocument(); |
Contributor
There was a problem hiding this comment.
can we use result.container.querySelector('svg') instead of another render?
dmytrokirpa
reviewed
Jun 25, 2026
| expect(result.current.menuIcon).toBeDefined(); | ||
| expect(React.isValidElement(result.current.menuIcon?.children)).toBe(true); | ||
|
|
||
| const { container } = render(result.current.menuIcon?.children as React.ReactElement); |
dmytrokirpa
approved these changes
Jun 25, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Addresses review comment: #36320 (comment)