-
Notifications
You must be signed in to change notification settings - Fork 108
[CLX-3022][Horizon] Learn screen accessibility #3290
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7fd7105
CLX-2920 scores tab a11y issues
andrasmaczak b0b248d
CLX-2919 program links a11y issues
andrasmaczak a954f3a
CLX-2917 ModuleItemCard a11y issues
andrasmaczak 63af4ee
CLX-2916 a11y fixes on expandable content
andrasmaczak a8cbf49
CLX-2915 a11y fixes on course details tabs
andrasmaczak e6a6836
Merge branch 'master' into CLX-3022-learn-screen-accessibility
andrasmaczak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libs/horizon/src/main/java/com/instructure/horizon/horizonui/Extensions.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.instructure.horizon.horizonui | ||
|
|
||
| import android.content.Context | ||
| import androidx.compose.ui.semantics.LiveRegionMode | ||
| import androidx.compose.ui.semantics.SemanticsPropertyReceiver | ||
| import androidx.compose.ui.semantics.liveRegion | ||
| import androidx.compose.ui.semantics.onClick | ||
| import androidx.compose.ui.semantics.stateDescription | ||
| import com.instructure.horizon.R | ||
|
|
||
| fun SemanticsPropertyReceiver.expandable(context: Context, expanded: Boolean) { | ||
| val expandedStateDesc = context.getString(R.string.a11y_expanded) | ||
| val collapsedStateDesc = context.getString(R.string.a11y_collapsed) | ||
| val expandActionLabel = context.getString(R.string.a11y_expand) | ||
| val collapseActionLabel = context.getString(R.string.a11y_collapse) | ||
|
|
||
| stateDescription = if (expanded) expandedStateDesc else collapsedStateDesc | ||
| liveRegion = LiveRegionMode.Assertive | ||
| onClick(if (expanded) collapseActionLabel else expandActionLabel) { false } | ||
| } | ||
|
|
||
| fun SemanticsPropertyReceiver.selectable(context: Context, selected: Boolean) { | ||
| val selectedStateDesc = context.getString(R.string.a11y_selected) | ||
| val unselectedStateDesc = context.getString(R.string.a11y_unselected) | ||
|
|
||
| stateDescription = if (selected) selectedStateDesc else unselectedStateDesc | ||
| liveRegion = LiveRegionMode.Assertive | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,12 @@ import androidx.compose.ui.layout.onGloballyPositioned | |
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.platform.LocalDensity | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.semantics.Role | ||
| import androidx.compose.ui.semantics.clearAndSetSemantics | ||
| import androidx.compose.ui.semantics.contentDescription | ||
| import androidx.compose.ui.semantics.role | ||
| import androidx.compose.ui.semantics.stateDescription | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.instructure.canvasapi2.utils.ContextKeeper | ||
|
|
@@ -55,7 +61,8 @@ fun SingleSelect( | |
| state: SingleSelectState, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
|
|
||
| val expandedState = stringResource(R.string.a11y_expanded) | ||
| val collapsedState = stringResource(R.string.a11y_collapsed) | ||
| Input( | ||
| label = state.label, | ||
| helperText = state.helperText, | ||
|
|
@@ -65,6 +72,15 @@ fun SingleSelect( | |
| .onFocusChanged { | ||
| state.onFocusChanged(it.isFocused) | ||
| } | ||
| .clearAndSetSemantics { | ||
| role = Role.DropdownList | ||
| stateDescription = if (state.isMenuOpen) expandedState else collapsedState | ||
| contentDescription = if (state.selectedOption != null) { | ||
| "${state.label}, ${state.selectedOption}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should string resources in this case. Different languages might handle a comma and word order differently. |
||
| } else { | ||
| state.label ?: "" | ||
| } | ||
| } | ||
| ) { | ||
| Column( | ||
| modifier = Modifier | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should string resources in this case. Different languages might handle a comma and word order differently.