-
Notifications
You must be signed in to change notification settings - Fork 567
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
Deduplicate ActionMenu.tsx
#3713
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({ | ||
children, | ||
align = 'start', | ||
'aria-labelledby': ariaLabelledby, |
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.
This was the only change that needed to be pulled in from the deleted file
size-limit report 📦
|
That IS very risky!! Looks like src/ActionMenu was only introduced in Feb 2023. I'm going to compare the two components closely to make sure we haven't been distributing bug fixes between them 💀 |
This comment was marked as outdated.
This comment was marked as outdated.
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.
Hi @iansan5653 👋🏻 Thanks so much for pushing this PR! I found that we even had an issue created to delete some duplicate files that includes ActionMenu.tsx
- I updated the description of the issue as we revereted some Dialog changes so only file that is duplicated for now is ActionMenu.tsx
Your changes is looking great, my only concern is that there is a manual import at dotcom from a file path. If we could fix that at dotcom before introducing this changes in primer/react side, I think it should be good. Let me know if I am misinterpreting anything!
Feel free to update your description withCloses https://github.com/primer/react/issues/2992
as well.
Thanks again for pushing this PR 🙌🏻
I think this is the import in question: import {ActionMenu} from '@primer/react/lib-esm/ActionMenu' This should still work with this change, because it will automatically resolve to |
The diff is changing as I work! The new one highlights a small difference in diff --git a/src/ActionMenu.tsx b/src/ActionMenu/ActionMenu.tsx
index 2f55d433..b84b1a65 100644
--- a/src/ActionMenu.tsx
+++ b/src/ActionMenu/ActionMenu.tsx
@@ -1,14 +1,14 @@
import React from 'react'
import {TriangleDownIcon} from '@primer/octicons-react'
-import {AnchoredOverlay, AnchoredOverlayProps} from './AnchoredOverlay'
-import {OverlayProps} from './Overlay'
-import {useProvidedRefOrCreate, useProvidedStateOrCreate, useMenuKeyboardNavigation} from './hooks'
-import {Divider} from './ActionList/Divider'
-import {ActionListContainerContext} from './ActionList/ActionListContainerContext'
-import {Button, ButtonProps} from './Button'
-import {useId} from './hooks/useId'
-import {MandateProps} from './utils/types'
-import {ForwardRefComponent as PolymorphicForwardRefComponent} from './utils/polymorphic'
+import {AnchoredOverlay, AnchoredOverlayProps} from '../AnchoredOverlay'
+import {OverlayProps} from '../Overlay'
+import {useProvidedRefOrCreate, useProvidedStateOrCreate, useMenuKeyboardNavigation} from '../hooks'
+import {Divider} from '../ActionList/Divider'
+import {ActionListContainerContext} from '../ActionList/ActionListContainerContext'
+import {Button, ButtonProps} from '../Button'
+import {useId} from '../hooks/useId'
+import {MandateProps} from '../utils/types'
+import {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
export type MenuContextProps = Pick<
AnchoredOverlayProps,
@@ -73,7 +73,7 @@ const Anchor = React.forwardRef<HTMLElement, ActionMenuAnchorProps>(({children,
})
/** this component is syntactical sugar 🍭 */
-export type ActionMenuButtonProps = ButtonProps & {
+export type ActionMenuButtonProps = Omit<ButtonProps, 'children'> & {
children: React.ReactNode
}
const MenuButton = React.forwardRef(({...props}, anchorRef) => {
@@ -91,12 +91,7 @@ type MenuOverlayProps = Partial<OverlayProps> &
*/
children: React.ReactNode
}
-const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({
- children,
- align = 'start',
- 'aria-labelledby': ariaLabelledby,
- ...overlayProps
-}) => {
+const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({children, align = 'start', ...overlayProps}) => {
// we typecast anchorRef as required instead of optional
// because we know that we're setting it in context in Menu
const {anchorRef, renderAnchor, anchorId, open, onOpen, onClose} = React.useContext(MenuContext) as MandateProps<
@@ -124,7 +119,7 @@ const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({
value={{
container: 'ActionMenu',
listRole: 'menu',
- listLabelledBy: ariaLabelledby || anchorId,
+ listLabelledBy: anchorId,
selectionAttribute: 'aria-checked', // Should this be here?
afterSelect: onClose,
}} |
👋🏻 @iansan5653 integration tests are complaining about not being able to resolve cc @siddharthkp as the release coordinator |
This reverts commit d277855.
This reverts commit d277855.
looking at the logs, and looks like the import reaches out for
It's because Looking at some other components, we usually don't have a Link: https://unpkg.com/browse/@primer/[email protected]/lib-esm/ActionMenu/ We have 3 options:
I think we should time box option 3 and use option 1 as a backup. I can work on this :) |
|
While looking into #3712, I noticed that
ActionMenu.tsx
is duplicated. It exists once insrc/
and once insrc/ActionMenu
. Thesrc/ActionMenu.tsx
file is the one being exported because it takes priority oversrc/ActionMenu/index.ts
, but thesrc/ActionMenu/ActionMenu.tsx
file is the one being tested and rendered in Storybook. This strikes me as particularly risky as the two could diverge over time (they already have in that thearia-labelledby
prop was only added to the file insrc/
).This appears to have been a leftover from some rearranging of files.
This PR cleans up the duplication by merging the two files and deleting the one in
src/
.ActionMenu
file #2992