From c97e771bc7f8bf55812974ab5acffe509a9c73b2 Mon Sep 17 00:00:00 2001 From: Andrii Vitiv Date: Thu, 19 Dec 2024 12:16:31 +0200 Subject: [PATCH 1/2] Add input autofocus to Sage Intacct setup page --- .../accounting/intacct/EnterSageIntacctCredentialsPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx b/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx index 29474431cd72..7ac4329c3a50 100644 --- a/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx +++ b/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx @@ -7,6 +7,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; +import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {connectToSageIntacct} from '@libs/actions/connections/SageIntacct'; @@ -24,6 +25,7 @@ type SageIntacctPrerequisitesPageProps = PlatformStackScreenProps {translate('workspace.intacct.enterCredentials')} - {formItems.map((formItem) => ( + {formItems.map((formItem, index) => ( Date: Thu, 19 Dec 2024 12:35:07 +0200 Subject: [PATCH 2/2] Fix infinite re-render Caused by setting a state on every render, which triggers another render. --- src/components/ConnectToNetSuiteFlow/index.tsx | 9 +++++---- src/components/ConnectToSageIntacctFlow/index.tsx | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/ConnectToNetSuiteFlow/index.tsx b/src/components/ConnectToNetSuiteFlow/index.tsx index 1d33eb07df4f..7957896d4006 100644 --- a/src/components/ConnectToNetSuiteFlow/index.tsx +++ b/src/components/ConnectToNetSuiteFlow/index.tsx @@ -59,10 +59,11 @@ function ConnectToNetSuiteFlow({policyID}: ConnectToNetSuiteFlowProps) { if (threeDotsMenuContainerRef) { if (!shouldUseNarrowLayout) { threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => { - setReuseConnectionPopoverPosition({ - horizontal: x + width, - vertical: y + height, - }); + const horizontal = x + width; + const vertical = y + height; + if (reuseConnectionPopoverPosition.horizontal !== horizontal || reuseConnectionPopoverPosition.vertical !== vertical) { + setReuseConnectionPopoverPosition({horizontal, vertical}); + } }); } diff --git a/src/components/ConnectToSageIntacctFlow/index.tsx b/src/components/ConnectToSageIntacctFlow/index.tsx index f93fce9c668a..807082365042 100644 --- a/src/components/ConnectToSageIntacctFlow/index.tsx +++ b/src/components/ConnectToSageIntacctFlow/index.tsx @@ -64,10 +64,11 @@ function ConnectToSageIntacctFlow({policyID}: ConnectToSageIntacctFlowProps) { if (threeDotsMenuContainerRef) { if (!shouldUseNarrowLayout) { threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => { - setReuseConnectionPopoverPosition({ - horizontal: x + width, - vertical: y + height, - }); + const horizontal = x + width; + const vertical = y + height; + if (reuseConnectionPopoverPosition.horizontal !== horizontal || reuseConnectionPopoverPosition.vertical !== vertical) { + setReuseConnectionPopoverPosition({horizontal, vertical}); + } }); }