gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.25k stars 268 forks source link

`DisclosureGroup` display issue #119

Closed PierreMardon closed 1 year ago

PierreMardon commented 1 year ago

Setup

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

Result

IMG_AEB221107048-1

Expected

IMG_696812BF98C4-1

Comments

When closing then expanding again, the display is correct.

gonzalezreal commented 1 year ago

Hi @PierreMardon,

I believe this issue has been fixed in the latest release: https://github.com/gonzalezreal/swift-markdown-ui/releases/tag/2.0.0