mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed Tree minWidth initial case to fill 100% width
This commit is contained in:
@@ -198,12 +198,15 @@ function InnerElementType({ style, ...rest }) {
|
||||
// We shouldn't retain this width across different conceptual trees though,
|
||||
// so when the user opens the "owners tree" view, we should discard the previous width.
|
||||
const divRef = useRef<HTMLDivElement | null>(null);
|
||||
const minWidthRef = useRef<number>(parseInt(style.width, 10));
|
||||
const minWidth = ownerStack.length > 0 ? '100%' : minWidthRef.current;
|
||||
const minWidthRef = useRef<number | null>(null);
|
||||
const minWidth =
|
||||
ownerStack.length > 0 || minWidthRef.current === null
|
||||
? '100%'
|
||||
: minWidthRef.current;
|
||||
useEffect(() => {
|
||||
if (divRef.current !== null) {
|
||||
minWidthRef.current = Math.max(
|
||||
minWidthRef.current,
|
||||
minWidthRef.current || 0,
|
||||
divRef.current.offsetWidth
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user