insin / insin/react-maskedinput

When addind masked-input to my application, the scrollTo() functions bugg.

Open
#135 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
727
Forks
191
PR merge metrics
No merged PRs in 30d

Description

When addind masked-input to my application, the scrollTo() functions bugg. Browser: Mozilla Firefox 68.7.0esr on Linux Debian 10 Buster.

Here the repository that reproduce my case: https://github.com/Hocoh/masked-input-is-makes-scrollTo-function-buggs

You will see that when masked-input is on the page to scroll at the page's top while rendering the next step cause bugg to occurs on the scrollTo's function.

Possibly other scroll API's functions bugg also.

Here a react snippet of the implementation:

`goNextStep=()=>{
let updateCurrentStep;

let {currentStep}=this.state;
currentStep = currentStep >= 1? 1: currentStep+1;

//setTimeout(()=>{
this.setState(currentState=>{
console.log("currentState.currentStep: ", currentState.currentStep)
updateCurrentStep=currentState.currentStep;
console.log("before modification => updateCurrentStep: ",updateCurrentStep)
updateCurrentStep= updateCurrentStep >= 2? 2: updateCurrentStep+=1;
console.log("after modification => updateCurrentStep: ",updateCurrentStep)
return({
currentStep:updateCurrentStep,
isInputFocus:false
})
}, this.FormRef.current.scrollTo(0,0)
)
// },10)

}

goToPrecedingStep=()=>{
let currentStep=this.state.currentStep;
currentStep=currentStep<=0?0:currentStep-1;
this.setState({
currentStep,
isInputFocus:false
},
() => this.FormRef.current.scrollTo(0,0)
)
}

render() {

let {
FormRef
}=this

let {
currentStep
}=this.state

let previousButton=() =>{
let{currentStep}=this.state
return (

Previous step

)
}
let nextButton =() => {
let{currentStep}=this.state
return(

Next step

)
}

return (





Step {currentStep +1}/3






{
currentStep>0 &&
previousButton()
}
{
currentStep<4&&
nextButton()
}




);
}
}

const FirstStep= (props)=>{
if(props.currentStep!==0) return null

return (






)
}

const SecondStep=(props)=>{
if(props.currentStep!==1) return null
return


}

const ThirdStep=(props)=>{
if(props.currentStep!==2) return null
return


}
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.