I have a list. When I click the show button in any of rows, the long text appears and the height of row auto gets taller enough to show all of the long text. However, when the list is in "edit" mode, the height of row can't auto get taller enough to show all of the long text. The long text is truncated. I have to push the list to the top manually and release, then the height of row auto gets taller and the long text can be completely displayed again. Is there any way to achieve the "auto" adjustment effect just the same as the "non-edit" mode?
struct ListEditTest: View {
@State private var selects: Set<Int> = []
var body: some View {
VStack{
EditButton()
List(selection: $selects){
ForEach(1..<5){
ItemInList(num: $0)
}
}
.listStyle(PlainListStyle())
}
}
}
struct ItemInList: View{
let num: Int
@State private var showDetail = false
var body: some View{
HStack{
Text("NO.\(num)")
Text("HelloWorld")
if showDetail{
Text("TooManyWordsTooManyWordsTooManyWordsTooManyWordsTooManyWordsTooManyWordsTooManyWordsTooManyWords")
Button {
showDetail.toggle()
} label: {
Text("Hide")
}
}else{
Button {
showDetail.toggle()
} label: {
Text("Show")
}
}
}
.buttonStyle(BorderlessButtonStyle())
}
}