Skip to content

Commit 7a8764f

Browse files
committed
fix(mobile): constrain New thread before its first measurement
1 parent 6d85e7c commit 7a8764f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/mobile/src/components/MaterialScrollComposeButton.android.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@ export function MaterialScrollComposeButton(props: {
2424
const typography = resolveScaledTextRole("footnote", appearance.baseFontSize);
2525
const { iconSize, fabSize } = useAndroidControlSizing();
2626
const [buttonWidth, setButtonWidth] = useState(fabSize);
27+
// Treat measurements at the width limit as overflow, allowing for native pixel rounding.
2728
const expanded =
28-
props.expanded && (props.maxWidth === undefined || buttonWidth <= props.maxWidth);
29+
props.expanded &&
30+
(props.maxWidth === undefined || Math.ceil(buttonWidth) < Math.floor(props.maxWidth));
2931
const rememberWidth = useCallback(({ width }: { width: number }) => {
3032
setButtonWidth((previous) => Math.max(previous, width));
3133
}, []);
3234
return (
3335
<View
3436
pointerEvents="box-none"
3537
className={props.className}
36-
style={[props.style, { left: 20, height: fabSize }]}
38+
style={[
39+
props.style,
40+
{ height: fabSize },
41+
props.maxWidth === undefined ? { left: 20 } : { width: Math.max(fabSize, props.maxWidth) },
42+
]}
3743
>
3844
<View pointerEvents="none" importantForAccessibility="no-hide-descendants">
3945
<Host

0 commit comments

Comments
 (0)