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

INSTUI-4145 MenuItem's onSelect type did not expose its value and selected types (v8) #1598

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ui-menu/src/Menu/MenuItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* SOFTWARE.
*/
/** @jsx jsx */
import React, { Component, MouseEventHandler } from 'react'
import React, { Component } from 'react'
import keycode from 'keycode'

import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons'
Expand Down Expand Up @@ -253,7 +253,7 @@ class MenuItem extends Component<MenuItemProps, MenuItemState> {
: 'false'
: undefined
}
onClick={this.handleClick as MouseEventHandler}
onClick={this.handleClick}
onKeyUp={createChainedFunction(onKeyUp, this.handleKeyUp)}
onKeyDown={createChainedFunction(onKeyDown, this.handleKeyDown)}
ref={this.handleRef}
Expand Down
16 changes: 14 additions & 2 deletions packages/ui-menu/src/Menu/MenuItem/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import type { ViewOwnProps } from '@instructure/ui-view'

type OnMenuItemSelect = (
e: React.MouseEvent<ViewOwnProps>,
value: MenuItemOwnProps['value'],
selected: MenuItemOwnProps['selected'],
value: MenuItemProps['value'],
selected: MenuItemProps['selected'],
args: MenuItem
) => void

Expand Down Expand Up @@ -74,8 +74,20 @@ type MenuItemOwnProps = {
* the element type to render as (will default to `<a>` if href is provided)
*/
as?: AsElementType
/**
* How this component should be rendered. If it's `checkbox` or `radio` it will
* display a checkmark based on its own 'selected' state, if it's `flyout` it will
* render an arrow after the label.
*/
type?: 'button' | 'checkbox' | 'radio' | 'flyout'
/**
* Arbitrary value that you can store in this component. Is sent out by the
* `onSelect` event
*/
value?: string | number
/**
* Value of the `href` prop that will be put on the underlying DOM element.
*/
href?: string
}

Expand Down