Skip to content

Commit f62b694

Browse files
authored
fix: add missing rippleColor in FAB (#4001)
1 parent 9cb6442 commit f62b694

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/components/FAB/FABGroup.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import {
33
Animated,
4+
ColorValue,
45
GestureResponderEvent,
56
StyleProp,
67
StyleSheet,
@@ -38,6 +39,7 @@ export type Props = {
3839
* - `toggleStackOnLongPress`: callback that is called when `FAB` is long pressed
3940
* - `size`: size of action item. Defaults to `small`. @supported Available in v5.x
4041
* - `testID`: testID to be used on tests
42+
* - `rippleColor`: color of the ripple effect.
4143
*/
4244
actions: Array<{
4345
icon: IconSource;
@@ -52,6 +54,7 @@ export type Props = {
5254
onPress: (e: GestureResponderEvent) => void;
5355
size?: 'small' | 'medium';
5456
testID?: string;
57+
rippleColor?: ColorValue;
5558
}>;
5659
/**
5760
* Icon to display for the `FAB`.
@@ -70,6 +73,10 @@ export type Props = {
7073
* Custom backdrop color for opened speed dial background.
7174
*/
7275
backdropColor?: string;
76+
/**
77+
* Color of the ripple effect.
78+
*/
79+
rippleColor?: ColorValue;
7380
/**
7481
* Function to execute on pressing the `FAB`.
7582
*/
@@ -208,6 +215,7 @@ const FABGroup = ({
208215
variant = 'primary',
209216
enableLongPressWhenStackOpened = false,
210217
backdropColor: customBackdropColor,
218+
rippleColor,
211219
}: Props) => {
212220
const theme = useInternalTheme(themeOverrides);
213221
const { current: backdrop } = React.useRef<Animated.Value>(
@@ -426,6 +434,7 @@ const FABGroup = ({
426434
accessibilityRole="button"
427435
testID={it.testID}
428436
visible={open}
437+
rippleColor={it.rippleColor}
429438
/>
430439
</View>
431440
);
@@ -457,6 +466,7 @@ const FABGroup = ({
457466
label={label}
458467
testID={testID}
459468
variant={variant}
469+
rippleColor={rippleColor}
460470
/>
461471
</View>
462472
</View>

src/components/__tests__/FABGroup.test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,37 @@ it('correctly adds label prop', () => {
184184
expect(getByText('Label test')).toBeTruthy();
185185
});
186186

187+
it('correct renders custom ripple color passed to FAB.Group and its item', () => {
188+
const { getByTestId } = render(
189+
<FAB.Group
190+
visible
191+
open
192+
label="Label test"
193+
testID="fab-group"
194+
rippleColor={'orange'}
195+
icon="plus"
196+
onStateChange={() => {}}
197+
actions={[
198+
{
199+
label: 'testing',
200+
onPress() {},
201+
icon: '',
202+
rippleColor: 'yellow',
203+
testID: 'fab-group-item',
204+
},
205+
]}
206+
/>
207+
);
208+
209+
expect(
210+
getByTestId('fab-group-container').props.children.props.rippleColor
211+
).toBe('orange');
212+
213+
expect(
214+
getByTestId('fab-group-item-container').props.children.props.rippleColor
215+
).toBe('yellow');
216+
});
217+
187218
it('animated value changes correctly', () => {
188219
const value = new Animated.Value(1);
189220
const { getByTestId } = render(

0 commit comments

Comments
 (0)