You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiTabbedContent] TypeError: Cannot read property 'content' of undefined #7350
Describe the bug
The EuiTabbedContent throws a type error when the tabs prop changes to a new (and different) list of tabs.
Impact and severity
Low impact because the workaround is easy. Adding key={uniqueStringAssociatedWithTabsList} causes the component to remount and therefore reinitialize its state based on the new tabs list.
Environment and versions
EUI version: 91.0.0
React version: 18.2.0
Browser: Chrome 117.0.5938.149
Operating System: Ubuntu 22.04.3
To Reproduce
Render an EuiTabbedContent component with one set of tabs
Cause a rerender that then uses another different set of tabs
Expected behavior
Tabs should refresh to be the new ones, and the first tab is selected.
Additional context
Found this similar bug, but didn't seem to be the exact same issue.
The issue is caused by the fact that the selected tab ID is stored in state and is initalised on construction of the component based on the props of the first render (here). During the first render, it's used to fetch the appropriate tab from the tabs list (here). However, when we change the tabs prop, a rerender is triggered, but the state of selectedTabId is not updated based on the new set of IDs, so that find() returns undefined, and the type error is thrown when we try to access content (here),
👋 Thank you for your suggestion or request! While the EUI team agrees that it's valid, it's unlikely that we will prioritize this issue on our roadmap. We'll leave the issue open if you or anyone else in the community wants to implement it by contributing to EUI. If not, this issue will auto close in one year.
Thanks for reporting this and including so many helpful details! I was able to reproduce it locally.
Replacing tabs in the runtime is pretty unusual, and I agree it has a low impact. We'll try to implement a fix soon, but we're happy to accept community contributions on this in the meantime!
We're not planning to work on this bug in the near future. It's an edge case, and there's a workaround available. As always, community contributions are welcome!
Activity
github-actions commentedon Nov 9, 2023
👋 Thank you for your suggestion or request! While the EUI team agrees that it's valid, it's unlikely that we will prioritize this issue on our roadmap. We'll leave the issue open if you or anyone else in the community wants to implement it by contributing to EUI. If not, this issue will auto close in one year.
tkajtoch commentedon Nov 9, 2023
Thanks for reporting this and including so many helpful details! I was able to reproduce it locally.
Replacing tabs in the runtime is pretty unusual, and I agree it has a low impact. We'll try to implement a fix soon, but we're happy to accept community contributions on this in the meantime!
tkajtoch commentedon Nov 20, 2023
We're not planning to work on this bug in the near future. It's an edge case, and there's a workaround available. As always, community contributions are welcome!
[EuiTabbedContent] Fixed issue of TypeError elastic#7350
[EuiTabbedContent] Fixed issue of TypeError elastic#7350