Skip to content

Commit 3a00234

Browse files
jaulzTrancever
authored andcommitted
fix: add wrapperStyle to Snackbar (#1865)
* fix: add wrapperStyle * style: fix lint * style: fix lint * test: update snapshots
1 parent ac3d8ac commit 3a00234

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

src/components/Snackbar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type Props = React.ComponentProps<typeof Surface> & {
4141
* Text content of the Snackbar.
4242
*/
4343
children: React.ReactNode;
44+
/**
45+
* Style for the wrapper of the snackbar
46+
*/
47+
wrapperStyle?: StyleProp<ViewStyle>;
4448
style?: StyleProp<ViewStyle>;
4549
ref?: React.RefObject<View>;
4650
/**
@@ -218,6 +222,7 @@ class Snackbar extends React.Component<Props, State> {
218222
onDismiss,
219223
theme,
220224
style,
225+
wrapperStyle,
221226
// eslint-disable-next-line @typescript-eslint/no-unused-vars
222227
duration,
223228
...rest
@@ -229,7 +234,10 @@ class Snackbar extends React.Component<Props, State> {
229234
}
230235

231236
return (
232-
<SafeAreaView pointerEvents="box-none" style={styles.wrapper}>
237+
<SafeAreaView
238+
pointerEvents="box-none"
239+
style={[styles.wrapper, wrapperStyle]}
240+
>
233241
<Surface
234242
pointerEvents="box-none"
235243
accessibilityLiveRegion="polite"

src/components/__tests__/__snapshots__/Snackbar.test.js.snap

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ exports[`renders snackbar with Text as a child 1`] = `
77
emulateUnlessSupported={true}
88
pointerEvents="box-none"
99
style={
10-
Object {
11-
"bottom": 0,
12-
"position": "absolute",
13-
"width": "100%",
14-
}
10+
Array [
11+
Object {
12+
"bottom": 0,
13+
"position": "absolute",
14+
"width": "100%",
15+
},
16+
undefined,
17+
]
1518
}
1619
>
1720
<View
@@ -79,11 +82,14 @@ exports[`renders snackbar with action button 1`] = `
7982
emulateUnlessSupported={true}
8083
pointerEvents="box-none"
8184
style={
82-
Object {
83-
"bottom": 0,
84-
"position": "absolute",
85-
"width": "100%",
86-
}
85+
Array [
86+
Object {
87+
"bottom": 0,
88+
"position": "absolute",
89+
"width": "100%",
90+
},
91+
undefined,
92+
]
8793
}
8894
>
8995
<View
@@ -242,11 +248,14 @@ exports[`renders snackbar with content 1`] = `
242248
emulateUnlessSupported={true}
243249
pointerEvents="box-none"
244250
style={
245-
Object {
246-
"bottom": 0,
247-
"position": "absolute",
248-
"width": "100%",
249-
}
251+
Array [
252+
Object {
253+
"bottom": 0,
254+
"position": "absolute",
255+
"width": "100%",
256+
},
257+
undefined,
258+
]
250259
}
251260
>
252261
<View

0 commit comments

Comments
 (0)