Skip to content

Commit

Permalink
update the event type to HTMLButtonElement
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolinisoup committed Dec 5, 2023
1 parent 66c70d0 commit 47b6862
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(

const onSelect = React.useCallback(
(
event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,
event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>,
// eslint-disable-next-line @typescript-eslint/ban-types
afterSelect?: Function,
) => {
Expand Down Expand Up @@ -182,15 +182,15 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
}

const clickHandler = React.useCallback(
(event: React.MouseEvent<HTMLElement>) => {
(event: React.MouseEvent<HTMLButtonElement>) => {
if (disabled) return
onSelect(event, afterSelect)
},
[onSelect, disabled, afterSelect],
)

const keyPressHandler = React.useCallback(
(event: React.KeyboardEvent<HTMLElement>) => {
(event: React.KeyboardEvent<HTMLButtonElement>) => {
if (disabled) return
if ([' ', 'Enter'].includes(event.key)) {
onSelect(event, afterSelect)
Expand Down
2 changes: 1 addition & 1 deletion src/ActionList/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ActionListItemProps = {
/**
* Callback that will trigger both on click selection and keyboard selection.
*/
onSelect?: (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void
onSelect?: (event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void
/**
* Is the `Item` is currently selected?
*/
Expand Down
4 changes: 2 additions & 2 deletions src/SegmentedControl/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ const Root: React.FC<React.PropsWithChildren<SegmentedControlProps>> = ({
<ActionList.Item
key={`segmented-control-action-btn-${index}`}
selected={index === selectedIndex}
onSelect={(event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => {
onSelect={(event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => {
isUncontrolled && setSelectedIndexInternalState(index)
onChange && onChange(index)
child.props.onClick && child.props.onClick(event as React.MouseEvent<HTMLLIElement>)
child.props.onClick && child.props.onClick(event as React.MouseEvent<HTMLButtonElement>)
}}
>
{ChildIcon && <ChildIcon />} {getChildText(child)}
Expand Down

0 comments on commit 47b6862

Please sign in to comment.