Skip to content

[Radio] onClick event target has wrong type #46587

@michele-menegatti

Description

@michele-menegatti

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/tsnr9qpf?file=src%2FDemo.tsx
  2. Check the console

Current behavior

The event of Radio onClick is typed as MouseEvent<HTMLButtonElement, MouseEvent>, but the target seems to always be an HTMLInputElement as you can see in the image below

Image

This is a problem because HTMLButtonElement doesn't have the 'value' attribute, so you can't access the value set to the radio button. I think this is because Radio inherit ButtonBase props.

Expected behavior

onClick should be typed as MouseEvent<HTMLInputElement, MouseEvent>

Context

No response

Your environment

npx @mui/envinfo
System:
    OS: Linux 5.0 undefined
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  Browsers:
    Chrome: Not Found

Search keywords: radio, event, target, onclick

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: radioThis is the name of the generic UI component, not the React module!

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions