Skip to content

Commit 417b34e

Browse files
fix: prevent parent expansion by skipping width/height setting to 100% on absolute SVG (#2752)
# Summary This PR fixes issue: #2689 In the SVG component when we do not pass `width` and `height` props, we set them to 100%. This caused problems when position is set to absolute because the SVG would expand beyond its parent. I added an extra check to only set width/height to 100% if `position !== 'absolute'`. ## Test Plan Run the example from issue: #2689 and check if Views are filled properly ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | MacOS | ✅ | | Android | ✅ | | Web | ✅ | ## Checklist - [X] I have tested this on a device and a simulator
1 parent 92e46a4 commit 417b34e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/elements/Svg.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ export default class Svg extends Shape<SvgProps> {
125125
strokeLinecap,
126126
strokeLinejoin,
127127
strokeMiterlimit,
128+
position,
128129
} = stylesAndProps;
129-
if (width === undefined && height === undefined) {
130+
if (
131+
width === undefined &&
132+
height === undefined &&
133+
position !== 'absolute'
134+
) {
130135
width = height = '100%';
131136
}
132137

0 commit comments

Comments
 (0)