-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Remove Duplicate Focusable Elements #83155
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 all commits
7fd7ba9
d094167
b47ab6e
9a80d96
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import React from 'react'; | ||
| import type {GestureResponderEvent, StyleProp, TextStyle} from 'react-native'; | ||
| import {PressableWithoutFeedback} from '@components/Pressable'; | ||
| import Text from '@components/Text'; | ||
| import useEnvironment from '@hooks/useEnvironment'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import type {FooterColumnRow} from '@pages/signin/SignInPageLayout/types'; | ||
| import {openLink as openLinkUtil} from '@userActions/Link'; | ||
| import CONST from '@src/CONST'; | ||
|
|
||
| type FooterRowProps = FooterColumnRow & { | ||
| text: string; | ||
| style: StyleProp<TextStyle>; | ||
| }; | ||
|
|
||
| function FooterRow({href, onPress, translationPath, text, style}: FooterRowProps) { | ||
| const styles = useThemeStyles(); | ||
| const {environmentURL} = useEnvironment(); | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| accessible | ||
| accessibilityRole={CONST.ROLE.LINK} | ||
| accessibilityLabel={text} | ||
| sentryLabel={translationPath} | ||
| onPress={() => { | ||
| if (onPress) { | ||
| onPress({} as GestureResponderEvent); | ||
| return; | ||
| } | ||
| if (href) { | ||
| openLinkUtil(href, environmentURL); | ||
| } | ||
| }} | ||
| > | ||
| <Text | ||
| accessible={false} | ||
| suppressHighlighting | ||
| style={[styles.link, style]} | ||
| > | ||
| {text} | ||
| </Text> | ||
| </PressableWithoutFeedback> | ||
| ); | ||
| } | ||
|
|
||
| export default FooterRow; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import React from 'react'; | ||
| import type {StyleProp, TextStyle} from 'react-native'; | ||
| import TextLink from '@components/TextLink'; | ||
| import type {FooterColumnRow} from '@pages/signin/SignInPageLayout/types'; | ||
|
|
||
| type FooterRowProps = FooterColumnRow & { | ||
| text: string; | ||
| style: StyleProp<TextStyle>; | ||
| }; | ||
|
|
||
| function FooterRow({href, onPress, text, style}: FooterRowProps) { | ||
|
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. ❌ CONSISTENCY-4 (docs)The Consider either:
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
| if (onPress) { | ||
| return ( | ||
| <TextLink | ||
| style={style} | ||
| onPress={onPress} | ||
| > | ||
| {text} | ||
| </TextLink> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <TextLink | ||
| style={style} | ||
| href={href} | ||
| > | ||
| {text} | ||
| </TextLink> | ||
| ); | ||
| } | ||
|
|
||
| export default FooterRow; | ||
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.
❌ CONSISTENCY-3 (docs)
The two branches of the ternary render nearly identical
FooterRowcomponents -- only theonPressvshrefprop differs. SinceFooterRowalready handles theonPress/hrefbranching internally (both the web and native implementations checkif (onPress)), the caller can pass the whole row without splitting:This eliminates the duplicated JSX block.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.