-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Menu Web Component [ PRIORITY 1 ] #27906
Menu Web Component [ PRIORITY 1 ] #27906
Conversation
…erbrady/fluentui-fork into web-components-v3
📊 Bundle size report🤖 This report was generated against 8057ad6e936dfd0473be71ce04bafad0ae582daa |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8d53f9c:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 8057ad6e936dfd0473be71ce04bafad0ae582daa (build) |
|
||
## **Design Spec** | ||
|
||
[Link to Menu Design Spec in Figma](https://www.figma.com/file/xyz12345/Menu?node-id=2%3A476) |
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.
Broken link, but I can't find the actual Menu spec in the folder with the rest of the specs.
|
||
| Fluent UI React 9 | Fluent Web Components | Description of difference | | ||
| ----------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `hasIcons` | | React implementation requires user to pass the `hasIcons` to align menu items with icons. The web components implimentation aligns content by default. | |
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.
Nit: spelling -> implementation
| Fluent UI React 9 | Fluent Web Components | Description of difference | | ||
| ----------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `hasIcons` | | React implementation requires user to pass the `hasIcons` to align menu items with icons. The web components implimentation aligns content by default. | | ||
| `hasCheckmarks` | | React implementation requires user to pass the `hasCheckmarks` to align menu items with checkmarks. The web components implimentation aligns content by default. | |
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.
Nit: spelling -> implementation
| `open` | public | `boolean` | `false` | Specifies if the menu is open or closed | | ||
| `menuContainer` | public | `HTMLElement` | | The container element for the menu items | | ||
| `openOnHover` | public | `boolean` | `false` | Sets whether the menu opens on hover of menu trigger | | ||
|
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.
Do we want to add the other openOn* attributes from the React V9 implementation, such as: openOnContext
, openOnChange
?
if (this.closeOnScroll) { | ||
document.removeEventListener('scroll', this.closeMenu); | ||
} |
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.
Edge case: if the close-on-scroll
attribute changes between open and close, the event listener is never removed.
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
* radio init * styles radio * reverts branch * input spec init * cleans up spec * formatting * updates component name to text input * updates component name in spec * menu: menu init * menu: updates README * menu: updates template, styles * menu: updates menu and stories * menu: removes dead code * menu: removes folder and file * yarn change * menu: removes tab index on template slot * menu changes based on feedback * menu: updates stories * menu, emits event on expanded change * menu: updatews attr/property name to align with fluent ( expand --> open ) * menu: cleans up code * reverts dead file * menu: removes block styling * enhances cleanup of autoUpdate, conditionally remove mouseover event listener * Add defaultPrevented check to handleTriggerKeydown function * menu: adds open/close features * menu: fixes spelling error in readme * menu: adds part selector to positioningRegion * menu: adds z-index css variable, updates docs accordingly * menu: adds attr changed callback for closeOnScroll to manage event listeners * menu: adds exports
Menu
Design Spec
Link to Menu Design Spec in Figma
Engineering Spec
The Menu component is responsible for managing menus and their associated menu items. It handles the open/close functionality, focus management, and positioning strategy for showing the menu items.
Use Case
Creating a menu component that can be used to display a list of options or actions.
Class:
Menu
Variables
Fields
menu
HTMLElement[]
trigger
HTMLElement[]
expanded
boolean
false
menuContainer
HTMLElement
openOnHover
boolean
false
Methods
setPositioning()
: Calculates and applies the positioning of the menu list based on available viewport space.focus()
: Focuses the first item in the menu.Attributes
expanded
open-on-hover
Slots
trigger
Template
Accessibility
WAI-ARIA Roles, States, and Properties
Preparation
Fluent Web Component v3 v.s Fluent React 9
Component and Slot Mapping
<Menu>
<fluent-menu>
<MenuList>
<fluent-menu-list>
<MenuItem>
<fluent-menu-item>
hasIcons
hasIcons
to align menu items with icons. The web components implimentation aligns content by default.hasCheckmarks
hasCheckmarks
to align menu items with checkmarks. The web components implimentation aligns content by default.