swift-markdown-ui icon indicating copy to clipboard operation
swift-markdown-ui copied to clipboard

`DisclosureGroup` display issue

Open PierreMardon opened this issue 2 years ago • 0 comments

Setup

  • iOS 15.5
  • iPhone 12

SwiftUI view:

struct FaqView: View {

    let faq: Faq
    let navigationBarCtaType: SettingsNavigationCTAType
    private let style = AppStyles.Settings()
    @State private var expandedIds: Set<String> = Set()

    func expanded(id: String) -> Binding<Bool> {
        Binding(get: { expandedIds.contains(id) },
                set: {
            if $0 {
                expandedIds.insert(id)
            } else {
                expandedIds.remove(id)
            }
        })
    }

    var body: some View {
        List {
            ForEach(faq.content) { section in
                DisclosureGroup(isExpanded: expanded(id: section.id)) {
                    ForEach(section.questions) { question in
                        DisclosureGroup(isExpanded: expanded(id: question.id)) {
                            VStack { // Hoped this would help but it doesn't
                                Markdown(question.answer)
                            }
                        } label: {
                            Text(question.title)
                        }
                    }
                } label: {
                    Text(section.title)
                }
            }
        }
        .listStyle(.plain)
    }
}

By default, all disclosure groups are not expanded.

Mardown:

# Alors

## Dites

### moi 

**Bold me**

*Ça geht's mol ?*

> Quote me [Link me](https://google.com) ![George]

(https://framapiaf.s3.framasoft.org/framapiaf/accounts/avatars/000/056/593/original/3dc8059101ae9d9e.jpg)

Long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long line.

Scenario

  • navigate to this view
  • expand first level (section)
  • expand second level (question)

Result

IMG_AEB221107048-1

Expected

IMG_696812BF98C4-1

Comments

When closing then expanding again, the display is correct.

PierreMardon avatar Aug 16 '22 16:08 PierreMardon