Topic: Linear Stepper causes next page animation to replay if onChange prop is present.
Expected behavior When updating a state in form element, the next step animation should not replay.
Actual behavior When form elements (select, Datepicker, radio, etc) are updating states in onChange when the state is declared in the same component as the parent MDBStepper (not MDBStepperStep), the next step animation replays on the second time a state is updated on that step. It can be any 2 states, even if they are different. The only thing that does not cause this behaviour is MDBInput and MDBTextArea. This also does not occur on the first step.
Resources (screenshots, code snippets etc.) This seems to be some weird bug with validation and the onChange event. This only seems to happen when both are specified. I don't have a live example as I am currently developing in a Vite dev environment.
Example Code:
const [dateState, setDateState] = useState();
<MDBStepper linear onChange={(number) => {setSteps(number)}}>
<MDBStepperForm>
<MDBStepperStep itemId={1}>
<p>Some arbitrary elements</p>
</MDBStepperStep>
<MDBStepperStep itemId={2}>
<MDBDatepicker onChange={(_value, date) => {
if (date.getTime() !== dateState.getTime()) {
setDateState(date)
}
}} />
</MDBStepperStep>
</MDBStepperForm>
</MDBStepper>
Mateusz Lazaru staff answered 5 months ago
I'll add a task to fix it. Thanks for reporting.
tgolen pro premium priority commented 2 weeks ago
I would love to see a fix for this. It makes the component unusable for me. Is there any update when a fix might be coming for this?
Mateusz Lazaru staff commented 2 weeks ago
Sorry, don't have the exact date yet. Although, there are 2 possible workarounds:
1: Turning off animation
.stepper-step .stepper-content {
animation-duration: 0s !important;
}
2: If you need the date only to submit the form and onchange re-render is not necessary, try to store input's value in the ref instead of state.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB React
- MDB Version: MDB5 8.0.0
- Device: MacBook Pro 16 Inch M2 Max
- Browser: Safari 14.4
- OS: macOS Sonoma 14.4
- Provided sample code: No
- Provided link: No