Skip to content

FormView - Add group element descriptions #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Sources/ArcGISToolkit/Components/FormView/GroupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ struct GroupView<Content>: View where Content: View {

var body: some View {
DisclosureGroup(self.element.label, isExpanded: $isExpanded) {
ForEach(visibleElements, id: \.label) { formElement in
if let element = formElement as? FieldFormElement {
viewCreator(element)
Group {
Text(element.description)
.accessibilityIdentifier("\(element.label) Description")
.font(.subheadline)
Divider()
ForEach(visibleElements, id: \.label) { formElement in
if let element = formElement as? FieldFormElement {
viewCreator(element)
}
}
}
// Reapply leading alignment for content within the DisclosureGroup
Expand Down
22 changes: 22 additions & 0 deletions UI Test Runner/UITests/FormViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ final class FormViewTests: XCTestCase {
let collapsedGroup = app.disclosureTriangles["Group with Multiple Form Elements 2"]
let expandedGroupFirstElement = app.staticTexts["MultiLine Text"]
let expandedGroup = app.disclosureTriangles["Group with Multiple Form Elements"]
let expandedGroupDescription = app.staticTexts["Group with Multiple Form Elements Description"]
let formTitle = app.staticTexts["group_formelement_UI_not_editable"]
let formViewTestsButton = app.buttons["FormView Tests"]

Expand All @@ -1295,6 +1296,16 @@ final class FormViewTests: XCTestCase {
"The first group header doesn't exist."
)

XCTAssertTrue(
expandedGroupDescription.exists,
"The expanded group's description doesn't exist."
)

XCTAssertEqual(
expandedGroupDescription.label,
"This Group is 'Expand initial state'\nThis group is Visible"
)

// Confirm the first element of the expanded group exists.
XCTAssertTrue(
expandedGroupFirstElement.exists,
Expand All @@ -1320,6 +1331,7 @@ final class FormViewTests: XCTestCase {
let formViewTestsButton = app.buttons["FormView Tests"]
let showElementsButton = app.buttons["show invisible form element"]
let hiddenElementsGroup = app.disclosureTriangles["Group with children that are visible dependent"]
let hiddenElementsGroupDescription = app.staticTexts["Group with children that are visible dependent Description"]
let groupElement = app.staticTexts["single line text 3"]

app.launch()
Expand All @@ -1340,6 +1352,16 @@ final class FormViewTests: XCTestCase {
"The group header doesn't exist."
)

XCTAssertTrue(
hiddenElementsGroupDescription.exists,
"The expanded group's description doesn't exist."
)

XCTAssertEqual(
hiddenElementsGroupDescription.label,
"The Form Elements in this group need the Radio button \"show invisible form elements\" to be selected, if you want to see them"
)

// Confirm the first element of the conditional group doesn't exist.
XCTAssertFalse(
groupElement.exists,
Expand Down