Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banner border still visible when the banner is hidden #3703

Closed
Ross-Landry opened this issue Feb 23, 2023 · 2 comments · Fixed by #3709
Closed

Banner border still visible when the banner is hidden #3703

Ross-Landry opened this issue Feb 23, 2023 · 2 comments · Fixed by #3709

Comments

@Ross-Landry
Copy link

Ross-Landry commented Feb 23, 2023

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The issue:
I've applied some color to the bottom border of a Banner. When the banner is hidden - the bottom border is still visible.
( Here's a snack demonstrating the issue )

My fix:
I applied a conditional style object to the banner container, that sets the bottom border width to 0 when the banner is not visible.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-paper/src/components/Banner.tsx b/node_modules/react-native-paper/src/components/Banner.tsx
index 4b52832..331f333 100644
--- a/node_modules/react-native-paper/src/components/Banner.tsx
+++ b/node_modules/react-native-paper/src/components/Banner.tsx
@@ -189,7 +189,7 @@ const Banner = ({
   return (
     <Surface
       {...rest}
-      style={[!theme.isV3 && styles.elevation, style]}
+      style={[!theme.isV3 && styles.elevation, style, !visible && styles.hiddenBorder]}
       theme={theme}
       {...(theme.isV3 && { elevation })}
     >
@@ -289,6 +289,9 @@ const styles = StyleSheet.create({
   elevation: {
     elevation: 1,
   },
+  hiddenBorder: {
+    borderBottomWidth:0
+  }
 });
 
 export default withInternalTheme(Banner);

This issue body was partially generated by patch-package.

@lukewalczak
Copy link
Member

Hey @Ross-Landry, thanks for the bug report. Could you please attach the snack presenting the issue?

@Ross-Landry
Copy link
Author

@lukewalczak Added a snack link. Thanks for your attention on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants