-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: break VoiceOver grouping on iOS so task checkbox is independently focusable #91530
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
c4b9452
37a3806
8e10ec2
2bd995f
a7cc4a0
661fac7
9523a10
72a67fd
e51b279
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import {delegateEmailSelector} from '@selectors/Account'; | ||
| import React from 'react'; | ||
| import React, {useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {StyleProp, ViewStyle} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
|
@@ -23,6 +23,7 @@ import useReportIsArchived from '@hooks/useReportIsArchived'; | |
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Accessibility from '@libs/Accessibility'; | ||
| import {callFunctionIfActionIsAllowed} from '@libs/actions/Session'; | ||
| import {canActionTask, completeTask, getTaskAssigneeAccountID, reopenTask} from '@libs/actions/Task'; | ||
| import ControlSelection from '@libs/ControlSelection'; | ||
|
|
@@ -33,6 +34,7 @@ import Navigation from '@libs/Navigation/Navigation'; | |
| import Parser from '@libs/Parser'; | ||
| import {getOriginalMessage} from '@libs/ReportActionsUtils'; | ||
| import {isCanceledTaskReport, isOpenTaskReport, isReportManager} from '@libs/ReportUtils'; | ||
| import shouldBreakAccessibilityGrouping from '@libs/shouldBreakAccessibilityGrouping'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
@@ -63,6 +65,8 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| const StyleUtils = useStyleUtils(); | ||
| const {translate} = useLocalize(); | ||
| const theme = useTheme(); | ||
| const isScreenReaderActive = Accessibility.useScreenReaderStatus(); | ||
| const shouldBreakGrouping = shouldBreakAccessibilityGrouping() && isScreenReaderActive; | ||
| const {originalReportID, anchor: contextMenuAnchorRef, shouldDisplayContextMenu = true} = useShowContextMenuState(); | ||
| const {checkIfContextMenuActive, onShowContextMenu} = useShowContextMenuActions(); | ||
| const originalMessage = getOriginalMessage(action); | ||
|
|
@@ -88,9 +92,17 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| // The reportAction might not contain details regarding the taskReport | ||
| // Only the direct parent reportAction will contain details about the taskReport | ||
| // Other linked reportActions will only contain the taskReportID and we will grab the details from there | ||
| const isTaskCompleted = !isEmptyObject(taskReport) | ||
| const isTaskCompletedFromOnyx = !isEmptyObject(taskReport) | ||
| ? taskReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && taskReport.statusNum === CONST.REPORT.STATUS_NUM.APPROVED | ||
| : action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED; | ||
| const [prevIsTaskCompletedFromOnyx, setPrevIsTaskCompletedFromOnyx] = useState(isTaskCompletedFromOnyx); | ||
| const [isTaskCompleted, setIsTaskCompleted] = useState(isTaskCompletedFromOnyx); | ||
|
|
||
| if (prevIsTaskCompletedFromOnyx !== isTaskCompletedFromOnyx) { | ||
| setPrevIsTaskCompletedFromOnyx(isTaskCompletedFromOnyx); | ||
| setIsTaskCompleted(isTaskCompletedFromOnyx); | ||
| } | ||
|
Comment on lines
+101
to
+107
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. This local state update logic now runs on every platform, not just iOS.
Contributor
Author
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. Scoped. |
||
|
|
||
| const parentReportAction = useParentReportAction(taskContextReport); | ||
| const taskAssigneeAccountID = getTaskAssigneeAccountID(taskContextReport, parentReportAction) ?? action?.childManagerAccountID ?? CONST.DEFAULT_NUMBER_ID; | ||
| const parentReport = useParentReport(taskContextReport?.reportID); | ||
|
|
@@ -106,6 +118,7 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| const iconWrapperStyle = StyleUtils.getTaskPreviewIconWrapper(hasAssignee ? avatarSize : undefined); | ||
|
|
||
| const shouldShowGreenDotIndicator = isOpenTaskReport(taskContextReport, action) && isReportManager(taskContextReport); | ||
| const taskAccessibilityLabel = taskTitleWithoutImage ? `${translate('task.task')}: ${taskTitleWithoutImage}` : translate('task.task'); | ||
|
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. |
||
| if (isDeletedParentAction) { | ||
| return <RenderHTML html={`<deleted-action>${translate('parentReportAction.deletedTask')}</deleted-action>`} />; | ||
| } | ||
|
|
@@ -121,6 +134,7 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| return ( | ||
| <View style={[styles.chatItemMessage, !hasAssignee && styles.mv1]}> | ||
| <PressableWithoutFeedback | ||
| accessible={shouldBreakGrouping ? false : undefined} | ||
| onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(taskReportID, undefined, undefined, Navigation.getActiveRoute()))} | ||
| onPressIn={() => canUseTouchScreen() && ControlSelection.block()} | ||
| onPressOut={() => ControlSelection.unblock()} | ||
|
|
@@ -135,7 +149,7 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| shouldUseHapticsOnLongPress | ||
| style={[styles.flexRow, styles.justifyContentBetween, style]} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('task.task')} | ||
| accessibilityLabel={taskAccessibilityLabel} | ||
| sentryLabel={CONST.SENTRY_LABEL.TASK.PREVIEW_CARD} | ||
| > | ||
| <View style={[styles.flex1, styles.flexRow, styles.alignItemsStart, styles.mr2]}> | ||
|
|
@@ -145,32 +159,62 @@ function TaskPreview({action, chatReportID, currentUserPersonalDetails, isHovere | |
| isChecked={isTaskCompleted} | ||
| disabled={!isTaskActionable} | ||
| onPress={callFunctionIfActionIsAllowed(() => { | ||
| setIsTaskCompleted((prev) => !prev); | ||
| if (isTaskCompleted) { | ||
| reopenTask(taskContextReport, parentReport, currentUserPersonalDetails.accountID, delegateEmail, taskReportID); | ||
| } else { | ||
| completeTask(taskContextReport, parentReport?.hasOutstandingChildTask ?? false, hasOutstandingChildTask, parentReportAction, delegateEmail, taskReportID); | ||
| } | ||
| })} | ||
| accessibilityLabel={translate('task.task')} | ||
| accessibilityLabel={taskAccessibilityLabel} | ||
| sentryLabel={CONST.SENTRY_LABEL.TASK.PREVIEW_CHECKBOX} | ||
| /> | ||
| </View> | ||
| {hasAssignee && ( | ||
| <UserDetailsTooltip accountID={taskAssigneeAccountID}> | ||
| <View> | ||
| <Avatar | ||
| containerStyles={[styles.mr2, isTaskCompleted ? styles.opacitySemiTransparent : undefined]} | ||
| source={avatar} | ||
| size={avatarSize} | ||
| avatarID={taskAssigneeAccountID} | ||
| type={CONST.ICON_TYPE_AVATAR} | ||
| /> | ||
| {shouldBreakGrouping ? ( | ||
| <PressableWithoutFeedback | ||
| onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(taskReportID, undefined, undefined, Navigation.getActiveRoute()))} | ||
| style={[styles.flex1, styles.flexRow, styles.alignItemsStart]} | ||
|
Krishna2323 marked this conversation as resolved.
Outdated
|
||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={taskAccessibilityLabel} | ||
| sentryLabel={CONST.SENTRY_LABEL.TASK.PREVIEW_CARD} | ||
| > | ||
| {hasAssignee && ( | ||
| <UserDetailsTooltip accountID={taskAssigneeAccountID}> | ||
| <View> | ||
| <Avatar | ||
| containerStyles={[styles.mr2, isTaskCompleted ? styles.opacitySemiTransparent : undefined]} | ||
| source={avatar} | ||
| size={avatarSize} | ||
| avatarID={taskAssigneeAccountID} | ||
| type={CONST.ICON_TYPE_AVATAR} | ||
| /> | ||
| </View> | ||
| </UserDetailsTooltip> | ||
| )} | ||
| <View style={[styles.alignSelfCenter, styles.flex1]}> | ||
| <RenderHTML html={getTaskHTML()} /> | ||
| </View> | ||
| </UserDetailsTooltip> | ||
| </PressableWithoutFeedback> | ||
| ) : ( | ||
| <> | ||
| {hasAssignee && ( | ||
| <UserDetailsTooltip accountID={taskAssigneeAccountID}> | ||
| <View> | ||
| <Avatar | ||
| containerStyles={[styles.mr2, isTaskCompleted ? styles.opacitySemiTransparent : undefined]} | ||
| source={avatar} | ||
| size={avatarSize} | ||
| avatarID={taskAssigneeAccountID} | ||
| type={CONST.ICON_TYPE_AVATAR} | ||
| /> | ||
| </View> | ||
| </UserDetailsTooltip> | ||
| )} | ||
| <View style={[styles.alignSelfCenter, styles.flex1]}> | ||
| <RenderHTML html={getTaskHTML()} /> | ||
| </View> | ||
| </> | ||
| )} | ||
| <View style={[styles.alignSelfCenter, styles.flex1]}> | ||
| <RenderHTML html={getTaskHTML()} /> | ||
| </View> | ||
| </View> | ||
| {shouldShowGreenDotIndicator && ( | ||
| <View style={iconWrapperStyle}> | ||
|
|
||

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.
Double states for the same state variable seems workaround to me
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.
Now local state is only used when
shouldBreakGrouping && isScreenReaderActive(iOS + VoiceOver).