Skip to content

Dynamic Panel - Support the accordion view for panels #10614

@JaneSjs

Description

@JaneSjs

T25589 - Accordion Panels
https://surveyjs.answerdesk.io/internal/ticket/details/T25589


In the meantime, it's possible to expand multiple panels: View Demo.
Consider introducing an API/option to enable the accordion mode where any previously open panel automatically collapses when a user expands a panel.


I suggest using the following code:

survey.onElementContentVisibilityChanged.add((sender, options) => {
    const el = options.element;
    const parentQ = el.parentQuestion;
    if (el.isPanel && !!parentQ && parentQ.getType() === "paneldynamic") {
        if (el.isExpanded) {
            parentQ.visiblePanels.forEach(p => {
                if (p !== el) {
                    p.collapse();
                }
            })
        }
    }
});

Here is the example

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions