-
Notifications
You must be signed in to change notification settings - Fork 111
[CLX-3694][Horizon] Accessibility fixes #3454
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,8 @@ import androidx.compose.ui.Alignment | |
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.layout.onGloballyPositioned | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.semantics.contentDescription | ||
| import androidx.compose.ui.semantics.semantics | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel | ||
| import androidx.navigation.NavGraph.Companion.findStartDestination | ||
|
|
@@ -70,7 +72,8 @@ fun DashboardCourseSection( | |
| mainNavController: NavHostController, | ||
| homeNavController: NavHostController, | ||
| shouldRefresh: Boolean, | ||
| refreshState: MutableStateFlow<List<Boolean>> | ||
| refreshState: MutableStateFlow<List<Boolean>>, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| val viewModel = hiltViewModel<DashboardCourseViewModel>() | ||
| val state by viewModel.uiState.collectAsState() | ||
|
|
@@ -84,29 +87,30 @@ fun DashboardCourseSection( | |
| } | ||
| } | ||
|
|
||
| DashboardCourseSection(state, mainNavController, homeNavController) | ||
| DashboardCourseSection(state, mainNavController, homeNavController, modifier) | ||
| } | ||
|
|
||
| @Composable | ||
| fun DashboardCourseSection( | ||
| state: DashboardCourseUiState, | ||
| mainNavController: NavHostController, | ||
| homeNavController: NavHostController | ||
| homeNavController: NavHostController, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| when(state.state) { | ||
| DashboardItemState.LOADING -> { | ||
| DashboardCourseCardContent( | ||
| DashboardCourseCardState.Loading, | ||
| { handleClickAction(it, mainNavController, homeNavController) }, | ||
| true, | ||
| modifier = Modifier.padding(horizontal = 24.dp) | ||
| modifier = modifier.padding(horizontal = 24.dp) | ||
| ) | ||
| } | ||
| DashboardItemState.ERROR -> { | ||
| DashboardCourseCardError({state.onRefresh {} }, Modifier.padding(horizontal = 24.dp)) | ||
| DashboardCourseCardError({state.onRefresh {} }, modifier.padding(horizontal = 24.dp)) | ||
| } | ||
| DashboardItemState.SUCCESS -> { | ||
| DashboardCourseSectionContent(state, mainNavController, homeNavController) | ||
| DashboardCourseSectionContent(state, mainNavController, homeNavController, modifier) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -115,13 +119,15 @@ fun DashboardCourseSection( | |
| private fun DashboardCourseSectionContent( | ||
| state: DashboardCourseUiState, | ||
| mainNavController: NavHostController, | ||
| homeNavController: NavHostController | ||
| homeNavController: NavHostController, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| // Display 4 cards at most | ||
| val pagerState = rememberPagerState { min(4, state.courses.size) } | ||
|
|
||
| Column( | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| modifier = modifier | ||
| ) { | ||
| if (state.programs.items.isNotEmpty()) { | ||
| DashboardPaginatedWidgetCard( | ||
|
|
@@ -151,6 +157,9 @@ private fun DashboardCourseSectionContent( | |
| val cardHeight = coordinates.size.height | ||
| if (cardHeight > maxCardHeight) { maxCardHeight = cardHeight } | ||
| } | ||
| .semantics { | ||
| contentDescription = "" | ||
|
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. Same concern as with DashboardWidgetCard - setting Additionally, this semantic block is only applied in the pager context when |
||
| } | ||
| ) | ||
| } | ||
| else -> { | ||
|
|
@@ -164,7 +173,6 @@ private fun DashboardCourseSectionContent( | |
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Button( | ||
|
|
||
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.
Setting
contentDescription = ""when not loading may interfere with accessibility. An empty content description can sometimes be problematic for screen readers. Consider usingclearAndSetSemantics { }instead if you want to clear all semantics, or verify that an empty string is the intended behavior for this use case.If the goal is to ensure child elements provide their own content descriptions, this approach is correct. Just wanted to flag for verification.