Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputMask: Autofocus crashes #4882

Closed
artemk-wingspan opened this issue Sep 6, 2023 · 0 comments · Fixed by #4884
Closed

InputMask: Autofocus crashes #4882

artemk-wingspan opened this issue Sep 6, 2023 · 0 comments · Fixed by #4884
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@artemk-wingspan
Copy link

Describe the bug

Setting autofocus: true to InputMaks causes app crash. It tries to access elementRef.current.value in onFocus method, but elementRef.current is null at the moment.

inputmask.esm.js:353
    Uncaught TypeError: Cannot read properties of null (reading 'value')
    at onFocus (inputmask.esm.js:353:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
    at executeDispatch (react-dom.development.js:8243:1)
    at processDispatchQueueItemsInOrder (react-dom.development.js:8275:1)
    at processDispatchQueue (react-dom.development.js:8288:1)
    at dispatchEventsForPlugins (react-dom.development.js:8299:1)
    at react-dom.development.js:8508:1
    at batchedEventUpdates$1 (react-dom.development.js:22396:1)
    at batchedEventUpdates (react-dom.development.js:3745:1)
    at dispatchEventForPluginEventSystem (react-dom.development.js:8507:1)
    at attemptToDispatchEvent (react-dom.development.js:6005:1)
    at dispatchEvent (react-dom.development.js:5924:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at discreteUpdates$1 (react-dom.development.js:22413:1)
    at discreteUpdates (react-dom.development.js:3756:1)
    at dispatchDiscreteEvent (react-dom.development.js:5889:1)
    at commitMount (react-dom.development.js:10244:1)
    at commitLifeCycles (react-dom.development.js:20752:1)
    at commitLayoutEffects (react-dom.development.js:23426:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at commitRootImpl (react-dom.development.js:23151:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at commitRoot (react-dom.development.js:22990:1)
    at performSyncWorkOnRoot (react-dom.development.js:22329:1)
    at react-dom.development.js:11327:1
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322:1)
    at flushSyncCallbackQueue (react-dom.development.js:11309:1)
    at scheduleUpdateOnFiber (react-dom.development.js:21893:1)
    at Object.enqueueSetState (react-dom.development.js:12467:1)
    at push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:365:1)
    at Router.js:34:1
    at listener (history.js:155:1)
    at history.js:173:1
    at Array.forEach (<anonymous>)
    at Object.notifyListeners (history.js:172:1)
    at setState (history.js:288:1)
    at history.js:369:1
    at Object.confirmTransitionTo (history.js:145:1)
    at Object.push (history.js:350:1)
    at Object.onSuccess (VerifyPhoneNumber.tsx:111:1)
    at useMutation.js:143:1

Reproducer

No response

PrimeReact version

9.6.1

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

I couldn't reproduce in isolated env.

Expected behavior

It doesn't try to reach onFocus before input reference is set, or at least doesn't crash b/c there is no ref.

@artemk-wingspan artemk-wingspan added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 6, 2023
@melloware melloware changed the title Autofocus crashes InputMask InputMask: Autofocus crashes Sep 6, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 6, 2023
melloware added a commit to melloware/primereact that referenced this issue Sep 6, 2023
@melloware melloware self-assigned this Sep 6, 2023
@melloware melloware added this to the 10.0.0 milestone Sep 6, 2023
melloware added a commit that referenced this issue Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants