mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.14k stars 32.35k forks source link

[joy-ui][Select] Clicking Select can submit form #39977

Open na2hiro opened 1 year ago

na2hiro commented 1 year ago

Duplicates

Latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/p/sandbox/elastic-dew-gslwht?file=%2Fsrc%2FApp.js%3A4%2C32&utm_source=dotnew

Steps:

  1. Just visit the page, where I placed mutation observer to the button rendered by Select component
  2. It shows alert that the button's "type" attribute changed from null to "button"

Current behavior 😯

A button is initially rendered as Select without type attribute, and then gets rerendered right after that. When the component can be clicked before it, it can result in submitting a form which is unexpected.

Expected behavior 🤔

A button should always be rendered with type="button"

Context 🔦

My end-to-end tests with Cypress fail due to submitting form when the test wants to select an option

Your environment 🌎

Chrome

(see codesandbox for library versions)

mj12albert commented 1 year ago

The root cause is the same as https://github.com/mui/material-ui/issues/38943