Skip to content
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

chore(menu): move to stable #13678

Merged
merged 23 commits into from
Jun 6, 2023
Merged

Conversation

janhassel
Copy link
Member

@janhassel janhassel commented Apr 27, 2023

Closes #13514
Ref #13467 (comment)

Affects:

  • Menu
    • MenuItem
    • MenuItemDivider
    • MenuItemGroup
    • MenuItemRadioGroup
    • MenuItemSelectable
  • useContextMenu
  • ComboButton
  • MenuButton
  • OverflowMenuV2
    • OverflowMenuV2 stays marked as "experimental". The component itself is moved to OverflowMenu/next and can be enabled with a feature flag (enable-v12-overflowmenu)

  • All files have a copyright banner
  • All components exported in src/index.js and should not be unstable_ prefixed
  • Component has a label in the github repository
    • Currently "component: context-menu" exists
    • @sstrubberg could you either rename this into "component: menu" or add additional ones if we wanna split it up?
      • "component: menu-button"
      • "component: combo-button"
      • "component: overflow-menu-v2"
  • Component should be documented on the website
    • Component should have a usage, style, and code tab
    • Component may have a component demo
  • For each component exported:
    • Component is written as a function declaration or uses forwardRef
    • Component has propTypes defined
      • Each prop type has a comment (used in storybook)
      • Prop types are as specific as needed, prefer PropTypes.shape over PropTypes.object if possible
    • Default props are listed as default args in the function definition (not in defaultProps)
      • Note: default props should be stable, in other words props like onClick = () => {} can cause re-renders since the function identity is not stable
    • Component has a story in <ComponentName>.stories.js
      • Component has an mdx document that follows our outline
      • mdx document covers at least common use-cases and provides a prop table
      • Stories cover at least common use-cases
      • Stories may include a Playground story for controls
      • Stories should mirror intended usage of the component
    • Component has unit/integration tests written in RTL for testing the component API
    • Component is tested via VRT for at least the initial render state
    • Component is tested via AVT for at least the initial render state

@janhassel janhassel requested review from a team as code owners April 27, 2023 12:26
@netlify
Copy link

netlify bot commented Apr 27, 2023

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7fa11d3
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/647f57409eab1d000766a228
😎 Deploy Preview https://deploy-preview-13678--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 27, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 7fa11d3
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/647f5740d4cfe300082cf59f
😎 Deploy Preview https://deploy-preview-13678--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@francinelucca
Copy link
Collaborator

Component has a label in the github repository
Currently "component: context-menu" exists
@sstrubberg could you either rename this into "component: menu" or add additional ones if we wanna split it up?
"component: menu-button"
"component: combo-button"
"component: overflow-menu-v2"

I vote for separate component tags 🙋🏽‍♀️

@sstrubberg
Copy link
Member

Component has a label in the github repository
Currently "component: context-menu" exists
@sstrubberg could you either rename this into "component: menu" or add additional ones if we wanna split it up?
"component: menu-button"
"component: combo-button"
"component: overflow-menu-v2"

I vote for separate component tags 🙋🏽‍♀️

I'm indifferent until I understand the ramifications. I'd love for the rest of @carbon-design-system/developers to weigh in.

@tay1orjones
Copy link
Member

It would be nice to be able to distinguish issues as relating to menu, and/or the components built atop it, menu-button, combo-button, etc.

@tay1orjones
Copy link
Member

I'm not sure if we should mark OverflowMenuV2 as stable under that name. The ideal for v12 would be that the existing OverflowMenu would be replaced with the internals of OverflowMenuV2 without a name change.

Would it make more sense to instead:

  • make a new feature flag like v12-enable-new-overflowMenu
  • Toggle in overflowmenu/index.js which OverflowMenu is used depending on the value of the feature flag
  • Update OverflowMenuv2 to just be a wrapper using FeatureFlags
<FeatureFlags flags={v12-enable-new-overflowMenu: true}>
  <OverflowMenu {…props}
</FeatureFlags>
  • Place a deprecation warning on OverflowMenuV2, pointing folks to instead import OverflowMenu and wrap it in a <FeatureFlag>. This can be done at each individual usage point, globally at the root of their app, or anywhere inbetween.

This way existing usages of OverflowMenuV2 aren't impacted, but we're providing a path to a more seamless upgrade where folks won't have to change imports.

Thoughts?

A few unknowns:

  • How will we handle the TypeScript typings of these two components under one export?

@janhassel
Copy link
Member Author

@tay1orjones This sounds reasonable, I can work on that. How would you structure the storybook with this change? Should there be a folder inside of the OverflowMenu stories called next which includes the three stories of OverflowMenuV2 / v12 OverflowMenu?

@tay1orjones
Copy link
Member

tay1orjones commented May 5, 2023

@janhassel I'm proposing a new way to document feature flags and organize their stories over in #13382 (comment)

I made a new file /components/Tile/Tile.featureflag.stories.js to house the stories. It's title is title: 'Experimental/Feature Flags/Tile'.

You could mirror the same for now and we could add the enable-v12-overflowmenu feature flag to the feature flag overview docs story once that other PR is merged. Thoughts?

@janhassel
Copy link
Member Author

@tay1orjones I updated the OverflowMenuV2 implementation as you described above. I was also able to already use the new WithDeprecationNotice story template 😀 https://deploy-preview-13678--carbon-components-react.netlify.app/?path=/story/experimental-unstable-overflowmenuv2--overflow-menu-v-2

Could you look over it and let me know if there's anything I missed?

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Percy caught this - the breadcrumb overflow icon is no longer horizontal like it should be

image

@janhassel
Copy link
Member Author

@tay1orjones Hmm, this seems to come from BreadcrumbItem as it's checking whether its child is an OverflowMenu based on its displayName. I added this explicit displayName again to the forwarding component in /OverflowMenu/index.js. Let me know if this makes sense!

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@tay1orjones
Copy link
Member

I just made the following labels:

We'll just reuse the existing component: overflow-menu for both versions with and without the new feature flag.

@tay1orjones
Copy link
Member

Once #13840 is in, we'll also want to make the change here to remove 'aria_child_tabbable' from the denylist in playwright.config.js and config/jest-config-carbon/matchers/toHaveNoACViolations.js

We had to add it in to get that PR to pass due to the Menu's None of the descendent elements with "menuitem" role is tabbable a11y violation #12728

@janhassel
Copy link
Member Author

@tay1orjones Just pushed the updates 👍

Copy link
Member

@laurenmrice laurenmrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, @janhassel ! ✨Just a couple of things:


Menu story

  • The caret icon in the first row of the menu needs to be vertically centered in the row with the text for all sizes. Currently, it looks to be a couple of pixels too high.
Screen Shot 2023-05-25 at 9 42 46 AM

Menu button with dividers story (Safari bug)

  • When the menu is open it overlaps the button.
Screen Shot 2023-05-25 at 9 53 28 AM

Context menu question

  • I don't see a story with the terminology "Context menu" specifically. Is Menu replacing this? For some reason, I was expecting to see it as its own component like Combo button, Menu button, and Overflow menu. I also can't find a way to right-click to get the menu to appear/open and was wondering if that interaction is still needed to display here or is it fine to only specify in our documentation?

@janhassel
Copy link
Member Author

@laurenmrice

  • Alignment – Good catch, should be fixed now
  • Overlay – this is happening because your browser window isn't high enough to show the full menu right now. The Menu uses the following heuristics for positioning itself:
    • Render below if there's enough space
    • Otherwise render above
    • If there's also not enough space, render below and stick to the bottom edge
  • ContextMenu story – From a technical perspective, the context menu is a regular Menu that uses the useContextMenu hook. Therefore the main story would be the Menu story and the right-click enabled one is located in the "hooks" folder in storybook: https://deploy-preview-13678--carbon-components-react.netlify.app/?path=/story/hooks-usecontextmenu--use-context-menu
    • @tay1orjones Feel free to chime in if I misunderstood this part from our conversation end of last year

@laurenmrice
Copy link
Member

@janhassel Okay sounds good.

@francinelucca
Copy link
Collaborator

@tay1orjones we still see the violation when removing the rule
image

I see the IBMa issue is still open so I don't think we can expect this false positive violation to not show up yet...

@tay1orjones
Copy link
Member

@francinelucca @janhassel Ah I'm sorry, I thought the aria-owns and aria-controls updates would fix it. Looks like we can't remove that yet until the false positive is addressed, IBMa/equal-access#1402.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just re-added aria_child_tabbable to the AC denylist. This looks good to merge and should pass now 👍

@kodiakhq kodiakhq bot merged commit 7a5a989 into carbon-design-system:main Jun 6, 2023
@janhassel janhassel deleted the 13514 branch June 7, 2023 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ContextMenu: Implementation
5 participants