mui / material-ui

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

Button Component value is not updated in case of conditional statement #36912

Open adamiku opened 1 year ago

adamiku commented 1 year ago

Hi,

I have tried to use the example Stepper Component and realize that the value of the Button is not updated at the last step:

https://github.com/mui/material-ui/blob/05127cf65b4250f836897428cd15829669ab8d6c/docs/data/material/components/steppers/HorizontalLinearStepper.tsx#L109

I have tried other components like Box and Typography but they work as expected (update the value to the latest state). Tried to duplicate the Button Component but references to the same state value and it works only if the other Button is clicked. Can you please check, looks like the Button component misses the latest state update if it was initiated from its own onClick.

Thanks

michaldudak commented 1 year ago

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://mui.com/r/issue-template), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

adamiku commented 1 year ago

Hi,

It is the official stepper example from the site: https://mui.com/material-ui/react-stepper/ https://codesandbox.io/s/denqrr?file=/demo.tsx If you click on the "Next" button, it should be changed to "Finish" at the 3rd step according to the source code, but it remains "Next"

mj12albert commented 1 year ago

@adamiku I can't reproduce this in CSB 🤔:

https://user-images.githubusercontent.com/4997971/232994664-58277eff-a0b6-45ba-9dd5-bcd1b073423f.mov

adamiku commented 1 year ago

Hmm interesting, i can reproduce it in codesandbox and even on localhost:

https://user-images.githubusercontent.com/15227670/233003228-837ffc1f-5de9-48e6-8d04-2309e029537e.mov

I am on a MAC, OS 13.3.1, in Chrome.

adamiku commented 1 year ago

Looks like in Safari it works fine, pretty weird:

https://user-images.githubusercontent.com/15227670/233004111-b3edca49-3430-45e1-ae09-f06d82e36f6e.mov