From f93f549dea0c67804e54e27cdc114f4ce07bd310 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 28 Aug 2024 03:31:41 +0530 Subject: [PATCH 1/2] fix: Expense - Unable to create a new line in description field with SHIFT+ENTER. Signed-off-by: krishna2323 --- src/CONST.ts | 65 +++++++++++++++++++++++++++++++++ src/components/Button/index.tsx | 4 +- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 30b0b5364d83..9dc2dc6d3873 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3787,6 +3787,71 @@ const CONST = { EXPENSIFY_LOGO_SIZE_RATIO: 0.22, EXPENSIFY_LOGO_MARGIN_RATIO: 0.03, }, + + /** + * Acceptable values for the `accessibilityRole` prop on react native components. + * + * **IMPORTANT:** Do not use with the `role` prop as it can cause errors. + * + * @deprecated ACCESSIBILITY_ROLE is deprecated. Please use CONST.ROLE instead. + */ + ACCESSIBILITY_ROLE: { + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + BUTTON: 'button', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + LINK: 'link', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + MENUITEM: 'menuitem', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + TEXT: 'text', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + RADIO: 'radio', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + IMAGEBUTTON: 'imagebutton', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + CHECKBOX: 'checkbox', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + SWITCH: 'switch', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + ADJUSTABLE: 'adjustable', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + IMAGE: 'image', + + /** + * @deprecated Please stop using the accessibilityRole prop and use the role prop instead. + */ + TEXTBOX: 'textbox', + }, + /** * Acceptable values for the `role` attribute on react native components. * diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index c6d93f93ee23..009c24609a91 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -137,13 +137,13 @@ type ButtonProps = Partial & { type KeyboardShortcutComponentProps = Pick; -const accessibilityRoles: string[] = Object.values(CONST.ROLE); +const accessibilityRoles: string[] = Object.values(CONST.ACCESSIBILITY_ROLE); function KeyboardShortcutComponent({isDisabled = false, isLoading = false, onPress = () => {}, pressOnEnter, allowBubble, enterKeyEventListenerPriority}: KeyboardShortcutComponentProps) { const isFocused = useIsFocused(); const activeElementRole = useActiveElementRole(); - const shouldDisableEnterShortcut = useMemo(() => accessibilityRoles.includes(activeElementRole ?? '') && activeElementRole !== CONST.ROLE.PRESENTATION, [activeElementRole]); + const shouldDisableEnterShortcut = useMemo(() => accessibilityRoles.includes(activeElementRole ?? '') && activeElementRole !== CONST.ACCESSIBILITY_ROLE.TEXTBOX, [activeElementRole]); const keyboardShortcutCallback = useCallback( (event?: GestureResponderEvent | KeyboardEvent) => { From 9c6936f9691c348589b40f433c7071f23ce6ee5d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 28 Aug 2024 04:06:28 +0530 Subject: [PATCH 2/2] update to CONST.ACCESSIBILITY_ROLE.TEXT. Signed-off-by: krishna2323 --- src/components/Button/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index 009c24609a91..f2995d9a56ea 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -143,7 +143,7 @@ function KeyboardShortcutComponent({isDisabled = false, isLoading = false, onPre const isFocused = useIsFocused(); const activeElementRole = useActiveElementRole(); - const shouldDisableEnterShortcut = useMemo(() => accessibilityRoles.includes(activeElementRole ?? '') && activeElementRole !== CONST.ACCESSIBILITY_ROLE.TEXTBOX, [activeElementRole]); + const shouldDisableEnterShortcut = useMemo(() => accessibilityRoles.includes(activeElementRole ?? '') && activeElementRole !== CONST.ACCESSIBILITY_ROLE.TEXT, [activeElementRole]); const keyboardShortcutCallback = useCallback( (event?: GestureResponderEvent | KeyboardEvent) => {