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

NPE caught in useFocusRowExpander #5353

Closed
2 tasks done
flannanl opened this issue May 28, 2024 · 2 comments · Fixed by #5363
Closed
2 tasks done

NPE caught in useFocusRowExpander #5353

flannanl opened this issue May 28, 2024 · 2 comments · Fixed by #5363
Assignees
Labels
component: Datagrid Sev 2 Aspects of design is broken and impedes users in a significant way, but has workaround. type: bug 🐛 Something isn't working

Comments

@flannanl
Copy link

Package

Carbon for IBM Products

Description

In my Datagrid, I am using useNestedRows. Occasionally, I am getting a NPE. I cannot consistently reproduce it. It just happens randomly.

TypeError: Cannot read properties of null (reading 'focus')
    at useFocusRowExpander.js:37:1
    at invokePassiveEffectCreate (react-dom.development.js:23487: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 flushPassiveEffectsImpl (react-dom.development.js:23574:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushPassiveEffects (react-dom.development.js:23447:1)
    at performSyncWorkOnRoot (react-dom.development.js:22269:1)

Looking at the code, the NPE is coming from:

    if (activeRow.length) {
      var rowExpander = activeRow[0].querySelector(".".concat(blockClass, "__row-expander"));
      rowExpander.focus(); <--
    }

Is it possible to put a NPE guard there? When this occurs, my page is blown up.

Component(s) impacted

  • Datagrid / useFocusRowExpander

Browser

Chrome

@carbon/ibm-products (previously @carbon/ibm-cloud-cognitive) version

1.72.2

Severity

Severity 2 = Aspects of design is broken, and impedes users in a significant way, but there is a way to complete their tasks. Affects major functionality, has a workaround.

Product/offering

IBM Cloud Projects

CodeSandbox or Stackblitz example

N/A

Steps to reproduce the issue (if applicable)

No response

Release date (if applicable)

No response

Code of Conduct

@flannanl
Copy link
Author

@matthewgallo Can we have this fix in v1?

@matthewgallo
Copy link
Member

Yes, here's the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Datagrid Sev 2 Aspects of design is broken and impedes users in a significant way, but has workaround. type: bug 🐛 Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants