Skip to content

Commit b400ef5

Browse files
authored
Only box up content for .view introspection (#305)
1 parent 2b8e809 commit b400ef5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Changelog
33

44
## master
55

6+
- Fixed: only box up content for `.view` introspection (#305)
7+
68
## [0.9.0]
79

810
- Added: view controller introspection (#298)

Sources/Introspect.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ struct IntrospectModifier<SwiftUIViewType: IntrospectableViewType, PlatformSpeci
7070
if let selector {
7171
content
7272
.background(
73-
// boxes up content without affecting appearance or behavior, for more accurate `.view` introspection
74-
Color.white
75-
.opacity(0)
76-
.accessibility(hidden: true)
73+
Group {
74+
// box up content for more accurate `.view` introspection
75+
if SwiftUIViewType.self == ViewType.self {
76+
Color.white
77+
.opacity(0)
78+
.accessibility(hidden: true)
79+
}
80+
}
7781
)
7882
.background(
7983
IntrospectionAnchorView(id: id)

0 commit comments

Comments
 (0)