Skip to content

[$250] "on or off, switch" is still not announced with the screen reader on Distance rates #82498

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.19-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #80496
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: macOS Sonoma 14.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Screen reader VoiceOver is enabled
  • Have a workspace
  • Distance rates are already enabled, and add other rates than the default
  1. Open https://staging.new.expensify.com/
    and login
  2. Navigate to Workspaces > Distance rates
  3. Try to select the available rate switch

Expected Result:

Test 4: Switch button in Distance rates - #76906
5. Verify that the corresponding switch is announced as Default Rate, [currency][amount] / mile, on, switch.

Actual Result:

Switch is only announced as "Default Rate, [currency][amount]", and the "on or off, switch" is still not announced with the screen reader on Distance rates

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7077737_1771064506610.82449-PR80496_-on_or_off_switch_is_still_not_announced_with_the_screen_reader_on_Distance_rates.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @marufsharifi
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022032182464097085675
  • Upwork Job ID: 2032182464097085675
  • Last Price Increase: 2026-03-12

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 14, 2026
  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 14, 2026
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 14, 2026
  4. melvin-bot commented on Feb 14, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

  5. melvin-bot commented on Feb 14, 2026

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  6. melvin-bot commented on Feb 14, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. daledah commented on Feb 14, 2026

    @daledah
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Switch is only announced as "Default Rate, [currency][amount]", and the "on or off, switch" is still not announced with the screen reader on Distance rates.

    What is the root cause of that problem?

    In PolicyDistanceRatesPage.tsx, the Switch component's accessibilityLabel only includes the rate name (value?.name), but it doesn't include the alternateText which contains the rate value (currency/amount per mile).

    The accessibilityLabel should include both the rate name and the rate value to provide complete information to screen reader users, similar to how it's implemented in WorkspaceCategoriesPage.tsx.

    What changes do you think we should make in order to solve the problem?

    Update the accessibilityLabel prop of the Switch component in PolicyDistanceRatesPage.tsx to include both the rate name and the alternateText (rate value):

    rightElement: (
        <Switch
            isOn={!!value?.enabled}
    -       accessibilityLabel={value?.name ?? ''}
    +       accessibilityLabel={`${value?.name ?? ''}, ${alternateText}`}
            onToggle={(newValue: boolean) => updateDistanceRateEnabled(newValue, value.customUnitRateID)}
            showLockIcon={!canDisableOrDeleteRate(value.customUnitRateID)}
            disabled={value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}
        />
    ),

    Note: We can consider adjusting the accessibilityLabel value

    What alternative solutions did you explore? (Optional)

    N/A

  8. thedavos commented on Feb 14, 2026

    @thedavos
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The Switch component in the Distance Rates page (Workspaces > Distance rates) does not announce its status ("on" or "off") or its role ("switch") when using a screen reader like VoiceOver. It only announces the rate name and amount, making it difficult for visually impaired users to know if a rate is enabled or disabled.

    What is the root cause of that problem?

    The root cause is two-fold:

    1. In src/components/Switch.tsx, the PressableWithFeedback component lacks an explicit accessibilityState definition for the checked property, which is essential for screen readers to translate the isOn boolean into "on/off" or "activated/deactivated" announcements.

    2. In src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx, the accessibilityLabel passed to the Switch component only contains the rate name, missing the currency and amount context required for a complete announcement.
      What changes do you think we should make in order to solve the problem?

    What changes do you think we should make in order to solve the problem?

    1. Update src/components/Switch.tsx to include the accessibilityState property in the PressableWithFeedback component. This ensures the component correctly communicates its state to the system's accessibility API.
      • Add accessibilityState={{checked: isOn, disabled: !!disabled}} to the PressableWithFeedback props.
    2. In src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx, update the distanceRatesList logic to provide a more descriptive accessibilityLabel to the Switch.
      • Construct a comprehensive label that includes both the name and the formatted rate (e.g., "Default Rate, USD 0.50 / mile").
      • Pass this new label to the Switch via the accessibilityLabel prop.

    By combining these changes, the screen reader will announce: "[Rate Name], [Amount] / [Unit], on/off, switch", fulfilling all the QA requirements.

    What alternative solutions did you explore? (Optional)

    None

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  9. annaweber830 commented on Feb 15, 2026

    @annaweber830
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On the Workspace Distance Rates page, VoiceOver announces each rate row as only its name and amount, but does not include the control state/role (on/off, switch) when users navigate to the toggle.

    What is the root cause of that problem?

    accessibilityLabel={item.accessibilityLabel ?? [item.text, item.text !== item.alternateText ? item.alternateText : undefined].filter(Boolean).join(', ')}
    accessibilityState={accessibilityState}
    isNested

    TableListItem rows are wrapped by this parent pressable, and if an item does not provide its own accessibilityLabel, the fallback label is only text + alternateText. In Distance Rates, that means screen readers announce just Default Rate, [currency][amount]; this causes the state/role announcement to be incomplete because the focused element label never includes switch semantics.

    What changes do you think we should make in order to solve the problem?

    Object.values(customUnitRates).map((value) => {
    const alternateText = `${convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${unitTranslation}`;
    return {
    rate: value.rate,
    value: value.customUnitRateID,
    text: value.name,
    alternateText,
    keyForList: value.customUnitRateID,
    isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
    pendingAction:
    value.pendingAction ??
    value.pendingFields?.rate ??
    value.pendingFields?.enabled ??
    value.pendingFields?.currency ??
    value.pendingFields?.taxRateExternalID ??
    value.pendingFields?.taxClaimablePercentage ??
    value.pendingFields?.name ??
    customUnit?.pendingFields?.attributes ??
    (policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? policy?.pendingAction : undefined),
    errors: value.errors ?? undefined,
    rightElement: (
    <Switch
    isOn={!!value?.enabled}
    accessibilityLabel={value?.name ?? ''}
    onToggle={(newValue: boolean) => updateDistanceRateEnabled(newValue, value.customUnitRateID)}
    showLockIcon={!canDisableOrDeleteRate(value.customUnitRateID)}
    disabled={value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}
    />
    ),

    const switchAccessibilityLabel = `${value?.name ?? ''}, ${alternateText}, ${value?.enabled ? translate('common.on') : translate('common.disabled')}, ${CONST.ROLE.SWITCH}`;
    
    return {
        rate: value.rate,
        value: value.customUnitRateID,
        text: value.name,
        alternateText,
        accessibilityLabel: switchAccessibilityLabel,
        keyForList: value.customUnitRateID,
        isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
        pendingAction:
            value.pendingAction ??
            value.pendingFields?.rate ??
            value.pendingFields?.enabled ??
            value.pendingFields?.currency ??
            value.pendingFields?.taxRateExternalID ??
            value.pendingFields?.taxClaimablePercentage ??
            value.pendingFields?.name ??
            customUnit?.pendingFields?.attributes ??
            (policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? policy?.pendingAction : undefined),
        errors: value.errors ?? undefined,
        rightElement: (
            <Switch
                isOn={!!value?.enabled}
                accessibilityLabel={switchAccessibilityLabel}
                onToggle={(newValue: boolean) => updateDistanceRateEnabled(newValue, value.customUnitRateID)}
                showLockIcon={!canDisableOrDeleteRate(value.customUnitRateID)}
                disabled={value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}
            />
        ),
    };
    

    This makes the focused row announcement include the full semantic string (name + amount + state + switch role) while keeping the switch control itself aligned with the same label, so VoiceOver users consistently hear ... on/off, switch.

    What alternative solutions did you explore? (Optional)

  10. github-actions commented on Feb 15, 2026

    @github-actions
    Contributor

    ⚠️ @annaweber830 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  11. marufsharifi commented on Feb 15, 2026

    @marufsharifi
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Workspaces > Distance rates, screen reader output is still not aligned with the final agreed behavior.

    Expected behavior after clarification:

    • The parent distance-rate row should announce full rate details once (name + amount/unit).
    • The switch should be a separate focus stop and announce only rate name + state/role (on/off, switch).
    • The switch label should not repeat [currency][amount].

    On affected web SR flows (macOS VoiceOver / Android web), focus/announcement order was inconsistent, causing missing switch state.

    Video demo of the issue in android-web:

    distance-rate-switch-android-web-issue.mp4

    What is the root cause of that problem?

    There are 2 core root causes before the fix:

    1. Distance rates rows rely on generic fallback labeling instead of explicit row labeling:
      In BaseListItem, when item.accessibilityLabel is missing, it falls back to text + alternateText, and the row defaults to button-like role semantics, This made SR focus behavior inconsistent for reaching/announcing the nested switch on web:
      accessibilityRole = getButtonRole(true),

      accessibilityLabel={item.accessibilityLabel ?? [item.text, item.text !== item.alternateText ? item.alternateText : undefined].filter(Boolean).join(', ')}
      accessibilityState={accessibilityState}
    2. Switch checked state semantics are not passed via accessibilityState.checked, which can make on/off announcement inconsistent in web SR combinations even when role="switch" is present:
      <PressableWithFeedback
      disabled={!disabledAction && disabled}
      onPress={handleSwitchPress}
      onLongPress={handleSwitchPress}
      role={CONST.ROLE.SWITCH}
      aria-checked={isOn}
      accessibilityLabel={enhancedAccessibilityLabel}

    What changes do you think we should make in order to solve the problem?

    Make accessibility behavior explicit in Distance Rates and keep labels aligned with the agreed expectation:

    1. In PolicyDistanceRatesPage:
      • Build switchAccessibilityLabel as rate name only.
      • Build rowAccessibilityLabel as name + amount/unit.
      • Set explicit row accessibilityLabel and row role semantics for stable announcement.
      • Keep switch label name-only.
    diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx
    @@
    -                const alternateText = `${convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${unitTranslation}`;
    +                const alternateText = `${convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${unitTranslation}`;
    +                const switchAccessibilityLabel = value?.name ?? '';
    +                const rowAccessibilityLabel = [switchAccessibilityLabel, alternateText].filter(Boolean).join(', ');
     
                     return {
                         rate: value.rate,
                         value: value.customUnitRateID,
                         text: value.name,
                         alternateText,
    +                    accessibilityLabel: rowAccessibilityLabel,
    +                    accessibilityRole: CONST.ROLE.LISTITEM,
                         keyForList: value.customUnitRateID,
                         isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
                         pendingAction:
    @@
                         rightElement: (
                             <Switch
                                 isOn={!!value?.enabled}
    -                            accessibilityLabel={value?.name ?? ''}
    +                            accessibilityLabel={switchAccessibilityLabel}
                                 onToggle={(newValue: boolean) => updateDistanceRateEnabled(newValue, value.customUnitRateID)}
                                 showLockIcon={!canDisableOrDeleteRate(value.customUnitRateID)}
                                 disabled={value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}
    1. In switch:
      • Add explicit accessibilityState={{checked, disabled}} so screen readers consistently announce on/off for the switch role.
    diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx
    @@
    -    return (
    +    const isSwitchDisabled = !disabledAction && !!disabled;
    +
    +    return (
             <PressableWithFeedback
    -            disabled={!disabledAction && disabled}
    +            disabled={isSwitchDisabled}
                 onPress={handleSwitchPress}
                 onLongPress={handleSwitchPress}
                 role={CONST.ROLE.SWITCH}
                 aria-checked={isOn}
    +            accessibilityState={{checked: isOn, disabled: isSwitchDisabled}}
                 accessibilityLabel={enhancedAccessibilityLabel}
    1. In ListItem types:
      • Add optional row accessibilityRole field so this behavior can be configured per screen without broad global changes.
    diff --git a/src/components/SelectionList/ListItem/types.ts b/src/components/SelectionList/ListItem/types.ts
    @@
     type ListItem<K extends string | number = string> = {
    @@
         /** Accessibility label for screen readers */
         accessibilityLabel?: string;
    +
    +    /** Accessibility role for the list item row */
    +    accessibilityRole?: Role;
    1. In TableListItem:
      • Pass per-item accessibilityRole down to BaseListItem.
      • Hide inner text nodes from the accessibility tree (title, currency, amount) when explicit row label is provided, so SR focus goes row -> switch.
    diff --git a/src/components/SelectionList/ListItem/TableListItem.tsx b/src/components/SelectionList/ListItem/TableListItem.tsx
    @@
             <BaseListItem
                 item={item}
    @@
                 onFocus={onFocus}
                 shouldSyncFocus={shouldSyncFocus}
                 hoverStyle={item.isSelected && styles.activeComponentBG}
    +            accessibilityRole={item.accessibilityRole}
                 shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
                 shouldShowRightCaret={shouldShowRightCaret}
             >
    @@
    -                    <View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch, titleContainerStyles]}>
    +                    <View
    +                        style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch, titleContainerStyles]}
    +                        accessible={item.accessibilityLabel ? false : undefined}
    +                        aria-hidden={item.accessibilityLabel ? true : undefined}
    +                    >

    Expectation references:
    #80496 (comment)
    #82498 (comment)
    #82498 (comment)
    #82498 (comment)

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    N/A

  12. 65 remaining items

  13. melvin-bot commented on Mar 28, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. mallenexpensify commented on Apr 2, 2026

    @mallenexpensify
    Contributor

    This issue is confusing.
    @shubham1206agra , why did you take over for @brunovjk ?

    @rushatgabhane Can I get the payout since I reviewed the PR?

    @shubham1206agra I'm not seeing much on the PR (and not much work on this issue either). At most I think $125 would be the amount, possibly less)

    Please tag me when you reply.

    @marufsharifi should you close your PR? It looks like you're due $250 cuz you were hired, raised PR and requested review.

    😰

  15. marufsharifi commented on Apr 2, 2026

    @marufsharifi
    Contributor

    @mallenexpensify, I've closed the pr. thanks.

  16. brunovjk commented on Apr 2, 2026

    @brunovjk
    Contributor

    This issue is confusing. @shubham1206agra , why did you take over for @brunovjk ?

    I reviewed the proposal. I was busy that day, and they managed to get another C+ to review the PR. I don't believe any payment is necessary on my part. Thank you.

  17. added and removed on Apr 3, 2026
  18. shubham1206agra commented on Apr 6, 2026

    @shubham1206agra
    Contributor

    This issue is confusing. @shubham1206agra , why did you take over for @brunovjk ?

    @rushatgabhane Can I get the payout since I reviewed the PR?

    @shubham1206agra I'm not seeing much on the PR (and not much work on this issue either). At most I think $125 would be the amount, possibly less)

    Please tag me when you reply.

    @mallenexpensify This is because our PR discussion was happening on Slack: https://expensify.slack.com/archives/C01GTK53T8Q/p1774022109182049 (the reason was the urgency of the issue). I would ask for $250 payment please

  19. mallenexpensify commented on Apr 6, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @marufsharifi paid $250 via Upwork - cuz hired/assigned, drafted PR and did tests
    Contributor+: @shubham1206agra due $125 via NewDot - not a full review on the PR nor any tests.

    @marufsharifi can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022032182464097085675

  20. marufsharifi commented on Apr 7, 2026

    @marufsharifi
    Contributor

    @mallenexpensify, I've accepted the offer. thanks.

  21. mallenexpensify commented on Apr 7, 2026

    @mallenexpensify
    Contributor

    @marufsharifi paid, summary updated above. Thx.

  22. JmillsExpensify commented on May 1, 2026

    @JmillsExpensify
    Contributor

    $125 approved for @shubham1206agra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

AccessibilityIssues affecting WACG accessibility on any platform.Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributorMelvin TriageAutomatic AI Analysis of an issueReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions