Opening a popover that contains tabs incorrectly determines the 'start' position of the indicator, which appears offset from the page, not the containing popover
The start position of the indicator should be calculated from the containing element.
It looks like this issue https://github.com/mui-org/material-ui/issues/9337 but it is not, because when we implement the useEffect solution it still does not correctly calculate the offset.
Looking at the internal material code something is going wrong in calculating tabMeta.left - tabsMeta.left on load because the laculation ends up being 16 - 173 (in our example), but if I change tab and then change back it correctly works out that it's 16 - 16. It's as though the tabsMeta calculates it's boundingClientRect too soon.
Steps:
Tries to use a setTimeout in a useEffect.
Tabs in a popover
| Tech | Version |
| ----------- | ------- |
| Material-UI | ^4.5.3 |
| React | ^16.10.2 |
| Browser | Chrome |
@AncientSwordRage We appreciate the time spend in the issue description and reproduction, but I'm closing as a duplicate #9337.
but it is not, because when we implement the useEffect solution it still does not correctly calculate the offset.
Consider the impact of the animation running.
but it is not, because when we implement the useEffect solution it still does not correctly calculate the offset.
Consider the impact of the animation running.
How would one do that?
You could use a setTimeout to account for it.
Set timeout doesn't have any effect. I can update the example to reproduce with what I've attempted.
You could use a setTimeout to account for it.
Edited main issue with my attempt to fix there.
@oliviertassinari I've also tested with useLayoutEffect and it made no difference.
I call updateIndicator() in an onEntered callback.
Most helpful comment
I call
updateIndicator()in anonEnteredcallback.