Skip to content

Commit

Permalink
Add OS check to tabIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
narin committed Aug 15, 2024
1 parent 0cd4a55 commit 9e09f75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/components/Snackbar/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import React, { FC, useEffect } from 'react'

import { Icon, IconProps } from '../Icon/Icon'
import { Spacer } from '../Spacer/Spacer'
import { isIOS } from '../../utils/OSfunctions'
import { isAndroid } from '../../utils/OSfunctions'
import { useTheme } from '../../utils'

type SnackbarButtonProps = {
Expand Down Expand Up @@ -158,7 +158,7 @@ export const Snackbar: FC<SnackbarProps> = (toast) => {

const containerProps: ViewProps = {
accessibilityViewIsModal: true, // iOS only
tabIndex: !isIOS() ? 0 : undefined, // Android only
tabIndex: isAndroid() ? 0 : undefined, // Android only
// Above props prevent screen reader from tap focusing elements behind the Snackbar
style: {
alignItems: 'center',
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/utils/OSfunctions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { useTranslation } from 'react-i18next'
/** True if iOS; a function to pull real time for unit tests so it can be changed */
export const isIOS = () => Platform.OS === 'ios'

/** True if Android; a function to pull real time for unit tests so it can be changed */
export const isAndroid = () => Platform.OS === 'android'

type address = {
street: string
city: string
Expand Down

0 comments on commit 9e09f75

Please sign in to comment.