Skip to content
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
2 changes: 0 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8653,8 +8653,6 @@ const CONST = {
ROTATE_BUTTON: 'Header-RotateButton',
CLOSE_BUTTON: 'Header-CloseButton',
MORE_BUTTON: 'Header-MoreButton',
PREVIOUS_BUTTON: 'Header-PreviousButton',
NEXT_BUTTON: 'Header-NextButton',
},
TOP_BAR: {
CANCEL_BUTTON: 'TopBar-CancelButton',
Expand Down
7 changes: 3 additions & 4 deletions src/components/FlatList/FlatListWithScrollKey/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type {ForwardedRef} from 'react';
import type {ListRenderItem, FlatList as RNFlatList} from 'react-native';
import type {CustomFlatListProps} from '@components/FlatList/FlatList/types';
import type {FlatListProps, ListRenderItem, FlatList as RNFlatList} from 'react-native';

type BaseFlatListWithScrollKeyProps<T> = Omit<CustomFlatListProps<T>, 'data' | 'initialScrollIndex' | 'onContentSizeChange'> & {
type BaseFlatListWithScrollKeyProps<T> = Omit<FlatListProps<T>, 'data' | 'initialScrollIndex' | 'onContentSizeChange'> & {
data: T[];
initialScrollKey?: string | null | undefined;
keyExtractor: (item: T, index: number) => string;
Expand All @@ -12,6 +11,6 @@ type BaseFlatListWithScrollKeyProps<T> = Omit<CustomFlatListProps<T>, 'data' | '
ref: ForwardedRef<RNFlatList>;
};

type FlatListWithScrollKeyProps<T> = Omit<BaseFlatListWithScrollKeyProps<T>, 'onContentSizeChange'> & Pick<CustomFlatListProps<T>, 'onContentSizeChange'>;
type FlatListWithScrollKeyProps<T> = Omit<BaseFlatListWithScrollKeyProps<T>, 'onContentSizeChange'> & Pick<FlatListProps<T>, 'onContentSizeChange'>;

export type {FlatListWithScrollKeyProps, BaseFlatListWithScrollKeyProps};
10 changes: 4 additions & 6 deletions src/components/PrevNextButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import {View} from 'react-native';
import type {GestureResponderEvent} from 'react-native';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
Expand All @@ -28,18 +27,17 @@ function PrevNextButtons({isPrevButtonDisabled, isNextButtonDisabled, onNext, on
const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'BackArrow']);
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();

return (
<View style={styles.flexRow}>
<PressableWithFeedback
accessible
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('common.previous')}
accessibilityLabel={CONST.ROLE.BUTTON}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use distinct accessibility labels for prev/next controls

Setting accessibilityLabel to CONST.ROLE.BUTTON makes both controls announce as the same generic "button" in screen readers, so users cannot distinguish the previous action from the next action. This is an accessibility regression for assistive-technology navigation; keep accessibilityRole as button, but restore descriptive localized labels per control.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-#80122 code already had CONST.ROLE.BUTTON.

disabled={isPrevButtonDisabled}
sentryLabel={CONST.SENTRY_LABEL.HEADER.PREVIOUS_BUTTON}
style={[styles.h7, styles.mr1, styles.alignItemsCenter, styles.justifyContentCenter]}
onPress={onPrevious}
sentryLabel={CONST.SENTRY_LABEL.PREV_NEXT_BUTTONS.PREV_BUTTON}
>
<View style={[styles.reportActionContextMenuMiniButton, {backgroundColor: theme.borderLighter}, isPrevButtonDisabled && styles.buttonOpacityDisabled]}>
<Icon
Expand All @@ -53,11 +51,11 @@ function PrevNextButtons({isPrevButtonDisabled, isNextButtonDisabled, onNext, on
<PressableWithFeedback
accessible
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('common.next')}
accessibilityLabel={CONST.ROLE.BUTTON}
disabled={isNextButtonDisabled}
sentryLabel={CONST.SENTRY_LABEL.HEADER.NEXT_BUTTON}
style={[styles.h7, styles.alignItemsCenter, styles.justifyContentCenter]}
onPress={onNext}
sentryLabel={CONST.SENTRY_LABEL.PREV_NEXT_BUTTONS.NEXT_BUTTON}
>
<View style={[styles.reportActionContextMenuMiniButton, {backgroundColor: theme.borderLighter}, isNextButtonDisabled && styles.buttonOpacityDisabled]}>
<Icon
Expand Down
57 changes: 23 additions & 34 deletions src/hooks/useReportScrollManager/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,39 @@
import {useCallback, useContext} from 'react';
import {useContext} from 'react';
// eslint-disable-next-line no-restricted-imports
import type {ScrollView} from 'react-native';
import {ActionListContext} from '@pages/inbox/ReportScreenContext';
import type ReportScrollManagerData from './types';

function useReportScrollManager(isInverted = true): ReportScrollManagerData {
const {flatListRef} = useContext(ActionListContext);
function useReportScrollManager(): ReportScrollManagerData {
const {flatListRef, scrollPositionRef} = useContext(ActionListContext);

/**
* Scroll to the provided index.
*/
const scrollToIndex = useCallback(
(index: number) => {
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToIndex({index});
},
[flatListRef],
);

/**
* Scroll to the visual bottom of the list.
*/
const scrollToBottom = useCallback(() => {
const scrollToIndex = (index: number) => {
if (!flatListRef?.current) {
return;
}
flatListRef.current.scrollToIndex({index});
};

if (isInverted) {
flatListRef.current.scrollToOffset({animated: false, offset: 0});
/**
* Scroll to the bottom of the inverted FlatList.
* When FlatList is inverted it's "bottom" is really it's top
*/
const scrollToBottom = () => {
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToEnd({animated: false});
}, [flatListRef, isInverted]);
scrollPositionRef.current = {offset: 0};
flatListRef.current?.scrollToOffset({animated: false, offset: 0});
};

/**
* Scroll to the end of the FlatList.
*/
const scrollToEnd = useCallback(() => {
const scrollToEnd = () => {
if (!flatListRef?.current) {
return;
}
Expand All @@ -53,18 +46,14 @@ function useReportScrollManager(isInverted = true): ReportScrollManagerData {
}

flatListRef.current.scrollToEnd({animated: false});
}, [flatListRef]);

const scrollToOffset = useCallback(
(offset: number) => {
if (!flatListRef?.current) {
return;
}
};

flatListRef.current.scrollToOffset({offset, animated: false});
},
[flatListRef],
);
const scrollToOffset = (offset: number) => {
if (!flatListRef?.current) {
return;
}
flatListRef.current.scrollToOffset({offset, animated: false});
};

return {ref: flatListRef, scrollToIndex, scrollToBottom, scrollToEnd, scrollToOffset};
}
Expand Down
18 changes: 7 additions & 11 deletions src/hooks/useReportScrollManager/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useCallback, useContext} from 'react';
import {useContext} from 'react';
import {ActionListContext} from '@pages/inbox/ReportScreenContext';
import type ReportScrollManagerData from './types';

function useReportScrollManager(isInverted = true): ReportScrollManagerData {
function useReportScrollManager(): ReportScrollManagerData {
const {flatListRef} = useContext(ActionListContext);

/**
Expand All @@ -17,20 +17,16 @@ function useReportScrollManager(isInverted = true): ReportScrollManagerData {
};

/**
* Scroll to the visual bottom of the list.
* Scroll to the bottom of the inverted FlatList.
* When FlatList is inverted it's "bottom" is really it's top
*/
const scrollToBottom = useCallback(() => {
const scrollToBottom = () => {
if (!flatListRef?.current) {
return;
}

if (isInverted) {
flatListRef.current.scrollToOffset({animated: false, offset: 0});
return;
}

flatListRef.current.scrollToEnd({animated: false});
}, [flatListRef, isInverted]);
flatListRef.current.scrollToOffset({animated: false, offset: 0});
};

/**
* Scroll to the end of the FlatList.
Expand Down
11 changes: 9 additions & 2 deletions src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function PureReportActionItem({
const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const {transitionActionSheetState} = ActionSheetAwareScrollView.useActionSheetAwareScrollViewActions();
const {translate, formatPhoneNumber, localeCompare, formatTravelDate, getLocalDateFromDatetime} = useLocalize();
const {translate, formatPhoneNumber, localeCompare, formatTravelDate, getLocalDateFromDatetime, datetimeToCalendarTime} = useLocalize();
const {showConfirmModal} = useConfirmModal();
const personalDetail = useCurrentUserPersonalDetails();
const {shouldUseNarrowLayout} = useResponsiveLayout();
Expand Down Expand Up @@ -2075,6 +2075,12 @@ function PureReportActionItem({
);
};

// Calculating accessibilityLabel for chat message with sender, date and time and the message content.
const displayName = getDisplayNameOrDefault(personalDetails?.[action.actorAccountID ?? CONST.DEFAULT_NUMBER_ID]);
const formattedTimestamp = datetimeToCalendarTime(action.created, false);
const plainMessage = getReportActionText(action);
const accessibilityLabel = `${displayName}, ${formattedTimestamp}, ${plainMessage}`;

return (
<View>
{shouldShowCreatedAction && createdActionContent}
Expand All @@ -2095,7 +2101,8 @@ function PureReportActionItem({
onSecondaryInteraction={showPopover}
preventDefaultContextMenu={draftMessage === undefined && !hasErrors}
withoutFocusOnSecondaryInteraction
accessibilityLabel={translate('accessibilityHints.chatMessage')}
accessibilityLabel={accessibilityLabel}
accessibilityHint={translate('accessibilityHints.chatMessage')}
accessibilityRole={CONST.ROLE.BUTTON}
sentryLabel={CONST.SENTRY_LABEL.REPORT.PURE_REPORT_ACTION_ITEM}
>
Expand Down
Loading
Loading