Remove fallback to render normall rather than using custom MaxSizedBox layout logic (#1340)
This commit is contained in:
parent
fd58d3267e
commit
1faf53a3af
|
@ -107,17 +107,10 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
|
||||||
const { addOverflowingId, removeOverflowingId } = useOverflowActions() || {};
|
const { addOverflowingId, removeOverflowingId } = useOverflowActions() || {};
|
||||||
|
|
||||||
const laidOutStyledText: StyledText[][] = [];
|
const laidOutStyledText: StyledText[][] = [];
|
||||||
// When maxHeight is not set, we render the content normally rather
|
const targetMaxHeight = Math.max(
|
||||||
// than using our custom layout logic. This should slightly improve
|
Math.round(maxHeight ?? Number.MAX_SAFE_INTEGER),
|
||||||
// performance for the case where there is no height limit and is
|
MINIMUM_MAX_HEIGHT,
|
||||||
// a useful debugging tool to ensure that our layouts are consist
|
);
|
||||||
// with the expected layout when there is no height limit.
|
|
||||||
// In the future we might choose to still apply our layout logic
|
|
||||||
// even in this case particularlly if there are cases where we
|
|
||||||
// intentionally diverse how certain layouts are rendered.
|
|
||||||
let targetMaxHeight;
|
|
||||||
if (maxHeight !== undefined) {
|
|
||||||
targetMaxHeight = Math.max(Math.round(maxHeight), MINIMUM_MAX_HEIGHT);
|
|
||||||
|
|
||||||
if (maxWidth === undefined) {
|
if (maxWidth === undefined) {
|
||||||
throw new Error('maxWidth must be defined when maxHeight is set.');
|
throw new Error('maxWidth must be defined when maxHeight is set.');
|
||||||
|
@ -139,7 +132,6 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
React.Children.forEach(children, visitRows);
|
React.Children.forEach(children, visitRows);
|
||||||
}
|
|
||||||
|
|
||||||
const contentWillOverflow =
|
const contentWillOverflow =
|
||||||
(targetMaxHeight !== undefined &&
|
(targetMaxHeight !== undefined &&
|
||||||
|
@ -168,14 +160,6 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
|
||||||
};
|
};
|
||||||
}, [id, totalHiddenLines, addOverflowingId, removeOverflowingId]);
|
}, [id, totalHiddenLines, addOverflowingId, removeOverflowingId]);
|
||||||
|
|
||||||
if (maxHeight === undefined) {
|
|
||||||
return (
|
|
||||||
<Box width={maxWidth} height={maxHeight} flexDirection="column">
|
|
||||||
{children}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const visibleStyledText =
|
const visibleStyledText =
|
||||||
hiddenLinesCount > 0
|
hiddenLinesCount > 0
|
||||||
? overflowDirection === 'top'
|
? overflowDirection === 'top'
|
||||||
|
|
Loading…
Reference in New Issue