Skip to content

Commit

Permalink
Fix link buttons not expanding to content width on android. turns out…
Browse files Browse the repository at this point in the history
… flex-basis doesn't work as expected there, but can use grow and shrink instead.

Signed-off-by: Josh Leyshon <[email protected]>
  • Loading branch information
josh-leyshon committed Jan 9, 2025
1 parent 6ca334a commit ba08b1b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/base/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ButtonProps as ReactNativeButtonProps } from 'react-native';
import { Button as ReactNativeButton, StyleSheet } from 'react-native';
import { Button as ReactNativeButton } from 'react-native';
import { colours } from '../../constants/colours';
import { Column } from '../../layout/flex';

Expand Down Expand Up @@ -28,17 +28,13 @@ export function Button({ title, onPress, colour, fitContent = false }: ButtonPro
return (
// Buttons are wrapped in a flex column so they can always expand horizontally
// to the width of their container.
<Column style={[styles.container, fitContent ? styles.fitContent : undefined]}>
<Column
{...(fitContent && {
grow: 1,
shrink: 1,
})}
>
<ReactNativeButton title={title} onPress={onPress} color={buttonColour} />
</Column>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
},
fitContent: {
flexBasis: 'auto',
},
});

0 comments on commit ba08b1b

Please sign in to comment.