'How to disable a DisclosureGroup?
SwiftUI allows to disable a NavigationLink. This fades its color it and prevents user from tapping it.
List {
NavigationLink(destination: Text("Destination")) {
Text("Some link")
}.disabled(true)
}
This behavior is not the same with DisclosureGroup. Only the arrow is faded and the text is still tappable.
List {
DisclosureGroup("Some group") {
Text("Some content")
}.disabled(true)
}
Is this a bug or is this the desired behavior? If so, is it possible to completely disable a DisclosureGroup?
Solution 1:[1]
Maybe this can serve as a workaround, setting .isExpanded to false always:
List {
DisclosureGroup("Some group", isExpanded: .constant(false)) {
Text("Some content")
}
.disabled(true)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ChrisR |
