Fixed Tree minWidth initial case to fill 100% width
Brian Vaughn committed
Apr 9, 2019 at 11:43 UTC
edc598e62a97b4858ecbc8cf4e2b72add8e366fb
1 file changed
+6
-3
src/devtools/views/Components/Tree.js
+6
-3
@@ -198,12 +198,15 @@ function InnerElementType({ style, ...rest }) {
198
// We shouldn't retain this width across different conceptual trees though,
199
// so when the user opens the "owners tree" view, we should discard the previous width.
200
const divRef = useRef<HTMLDivElement | null>(null);
201
- const minWidthRef = useRef<number>(parseInt(style.width, 10));
202
- const minWidth = ownerStack.length > 0 ? '100%' : minWidthRef.current;
201
+ const minWidthRef = useRef<number | null>(null);
202
+ const minWidth =
203
+ ownerStack.length > 0 || minWidthRef.current === null
204
+ ? '100%'
205
+ : minWidthRef.current;
206
useEffect(() => {
207
if (divRef.current !== null) {
208
minWidthRef.current = Math.max(
206
- minWidthRef.current,
209
+ minWidthRef.current || 0,
210
divRef.current.offsetWidth
211
);
212
}