From 0d34352d5ce78a1ca8a7ecf74d8f02530cfe07e2 Mon Sep 17 00:00:00 2001 From: jameswilddev Date: Fri, 26 Nov 2021 12:41:25 +0000 Subject: [PATCH] Fix backgrounds accepting presses. --- .../index.tsx | 6 +++- .../unit.tsx | 7 ++-- .../createImageBackgroundComponent/index.tsx | 9 ++++- .../createImageBackgroundComponent/unit.tsx | 33 +++++++++++++------ 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/components/createFlatColorBackgroundComponent/index.tsx b/components/createFlatColorBackgroundComponent/index.tsx index d016230d..3ef6cc67 100644 --- a/components/createFlatColorBackgroundComponent/index.tsx +++ b/components/createFlatColorBackgroundComponent/index.tsx @@ -21,5 +21,9 @@ export const createFlatColorBackgroundComponent = ( }, }); - return ({ size, children }) => {children}; + return ({ size, children }) => ( + + {children} + + ); }; diff --git a/components/createFlatColorBackgroundComponent/unit.tsx b/components/createFlatColorBackgroundComponent/unit.tsx index bfacbcd0..63b9c61d 100644 --- a/components/createFlatColorBackgroundComponent/unit.tsx +++ b/components/createFlatColorBackgroundComponent/unit.tsx @@ -13,7 +13,7 @@ test(`renders as expected when fitting the content`, () => { ); expect(unwrapRenderedFunctionComponent(rendered)).toEqual( - + Test Content ); @@ -29,7 +29,10 @@ test(`renders as expected when filling the container`, () => { ); expect(unwrapRenderedFunctionComponent(rendered)).toEqual( - + Test Content ); diff --git a/components/createImageBackgroundComponent/index.tsx b/components/createImageBackgroundComponent/index.tsx index 940e1a5b..1f4236ce 100644 --- a/components/createImageBackgroundComponent/index.tsx +++ b/components/createImageBackgroundComponent/index.tsx @@ -3,6 +3,10 @@ import { Image, ImageSourcePropType, StyleSheet, View } from "react-native"; const styles = StyleSheet.create({ image: { + width: `100%`, + height: `100%`, + }, + imageWrapper: { position: `absolute`, left: 0, top: 0, @@ -29,8 +33,11 @@ export const createImageBackgroundComponent = ( {...(size === `fillsContainer` ? { style: styles.containerFillingView } : {})} + pointerEvents="box-none" > - + + + {children} ); diff --git a/components/createImageBackgroundComponent/unit.tsx b/components/createImageBackgroundComponent/unit.tsx index 861b5af5..98c0ff8a 100644 --- a/components/createImageBackgroundComponent/unit.tsx +++ b/components/createImageBackgroundComponent/unit.tsx @@ -13,9 +13,9 @@ test(`renders as expected when fitting the content`, () => { ); expect(unwrapRenderedFunctionComponent(rendered)).toEqual( - - + { width: `100%`, height: `100%`, }} - resizeMode="cover" - /> + > + + Test Content ); @@ -40,9 +45,8 @@ test(`renders as expected when filling the container`, () => { ); expect(unwrapRenderedFunctionComponent(rendered)).toEqual( - - + { width: `100%`, height: `100%`, }} - resizeMode="cover" - /> + pointerEvents="none" + > + + Test Content );