mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
Fix table dissapear after switching tabs (#11096)
This commit is contained in:
parent
0e9821519d
commit
b14f19f8f7
@ -2265,6 +2265,29 @@ export default function AssetsTable(props: AssetsTableProps) {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
// In some browsers, at least in Chrome 126,
|
||||||
|
// in some situations, when an element has a
|
||||||
|
// 'container-size' style, and the parent element is hidden,
|
||||||
|
// the browser can't calculate the element's size
|
||||||
|
// and thus the element doesn't appear when we unhide the parent.
|
||||||
|
// The only way to fix that is to force browser to recalculate styles
|
||||||
|
// So the trick is to change a property, trigger style recalc(`getBoundlingClientRect()`)
|
||||||
|
// and remove the property.
|
||||||
|
// since everything is happening synchronously, user won't see a broken layout during recalculation
|
||||||
|
if (!hidden && rootRef.current) {
|
||||||
|
for (let i = 0; i < rootRef.current.children.length; i++) {
|
||||||
|
const element = rootRef.current.children[i]
|
||||||
|
|
||||||
|
if (element instanceof HTMLElement) {
|
||||||
|
element.style.width = '0px'
|
||||||
|
element.getBoundingClientRect()
|
||||||
|
element.style.width = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [hidden])
|
||||||
|
|
||||||
// This is required to prevent the table body from overlapping the table header, because
|
// This is required to prevent the table body from overlapping the table header, because
|
||||||
// the table header is transparent.
|
// the table header is transparent.
|
||||||
const updateClipPath = useOnScroll(() => {
|
const updateClipPath = useOnScroll(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user