From 420ef2180545bac80e6233ae9b50d06d862038b1 Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:01:33 +0100 Subject: [PATCH 1/4] fix workspace button blur for enter event --- src/components/WorkspaceSwitcherButton.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/WorkspaceSwitcherButton.tsx b/src/components/WorkspaceSwitcherButton.tsx index a94f54682c85..297f66ffc8ba 100644 --- a/src/components/WorkspaceSwitcherButton.tsx +++ b/src/components/WorkspaceSwitcherButton.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import React, {useMemo, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; @@ -23,6 +23,8 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) { const {translate} = useLocalize(); const theme = useTheme(); + const pressableRef = useRef(null); + const {source, name, type} = useMemo(() => { if (!policy) { return {source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR}; @@ -39,14 +41,16 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) { return ( + onPress={() =>{ + pressableRef?.current?.blur(); interceptAnonymousUser(() => { - Navigation.navigate(ROUTES.WORKSPACE_SWITCHER); + Navigation.navigate(ROUTES.WORKSPACE_SWITCHER); }) - } + }} > {({hovered}) => ( Date: Tue, 2 Apr 2024 14:27:10 +0200 Subject: [PATCH 2/4] fix prettier --- src/components/WorkspaceSwitcherButton.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/WorkspaceSwitcherButton.tsx b/src/components/WorkspaceSwitcherButton.tsx index 297f66ffc8ba..5116eaed3806 100644 --- a/src/components/WorkspaceSwitcherButton.tsx +++ b/src/components/WorkspaceSwitcherButton.tsx @@ -45,11 +45,11 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) { accessibilityRole={CONST.ROLE.BUTTON} accessibilityLabel={translate('common.workspaces')} accessible - onPress={() =>{ + onPress={() => { pressableRef?.current?.blur(); interceptAnonymousUser(() => { - Navigation.navigate(ROUTES.WORKSPACE_SWITCHER); - }) + Navigation.navigate(ROUTES.WORKSPACE_SWITCHER); + }); }} > {({hovered}) => ( From ccd6d5311a0cdad43bfc30218f62cb40fbd2544a Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:19:35 +0200 Subject: [PATCH 3/4] add suggested View type to ref --- src/components/WorkspaceSwitcherButton.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/WorkspaceSwitcherButton.tsx b/src/components/WorkspaceSwitcherButton.tsx index 5116eaed3806..5906a7fcb039 100644 --- a/src/components/WorkspaceSwitcherButton.tsx +++ b/src/components/WorkspaceSwitcherButton.tsx @@ -8,6 +8,7 @@ import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Policy} from '@src/types/onyx'; +import type { View } from 'react-native'; import * as Expensicons from './Icon/Expensicons'; import {PressableWithFeedback} from './Pressable'; import SubscriptAvatar from './SubscriptAvatar'; @@ -23,7 +24,7 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) { const {translate} = useLocalize(); const theme = useTheme(); - const pressableRef = useRef(null); + const pressableRef = useRef(null); const {source, name, type} = useMemo(() => { if (!policy) { From b5a09b79c421539d55d62965b7ebbb8ba7aa0147 Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:28:13 +0200 Subject: [PATCH 4/4] fix import order --- src/components/WorkspaceSwitcherButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/WorkspaceSwitcherButton.tsx b/src/components/WorkspaceSwitcherButton.tsx index 5906a7fcb039..2b9b3480f96d 100644 --- a/src/components/WorkspaceSwitcherButton.tsx +++ b/src/components/WorkspaceSwitcherButton.tsx @@ -1,4 +1,5 @@ import React, {useMemo, useRef} from 'react'; +import type {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; @@ -8,7 +9,6 @@ import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Policy} from '@src/types/onyx'; -import type { View } from 'react-native'; import * as Expensicons from './Icon/Expensicons'; import {PressableWithFeedback} from './Pressable'; import SubscriptAvatar from './SubscriptAvatar';