-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: Subscription size - Decimal point can be inserted and not removed on the confirmation page. #44507
Merged
AndrewGable
merged 4 commits into
Expensify:main
from
Krishna2323:krishnna2323/issue/43796
Jul 22, 2024
Merged
fix: Subscription size - Decimal point can be inserted and not removed on the confirmation page. #44507
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7b25554
fix: Subscription size - Decimal point can be inserted and not remove…
Krishna2323 518d99c
minor updated.
Krishna2323 518f36d
Merge branch 'Expensify:main' into krishnna2323/issue/43796
Krishna2323 08c4a55
add suggested changes.
Krishna2323 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||
import type {StackScreenProps} from '@react-navigation/stack'; | ||||||||||
import React from 'react'; | ||||||||||
import {InteractionManager} from 'react-native'; | ||||||||||
import {useOnyx} from 'react-native-onyx'; | ||||||||||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||||||||||
import ScreenWrapper from '@components/ScreenWrapper'; | ||||||||||
|
@@ -8,6 +9,7 @@ import useSubStep from '@hooks/useSubStep'; | |||||||||
import type {SubStepProps} from '@hooks/useSubStep/types'; | ||||||||||
import Navigation from '@libs/Navigation/Navigation'; | ||||||||||
import type {SettingsNavigatorParamList} from '@navigation/types'; | ||||||||||
import * as FormActions from '@userActions/FormActions'; | ||||||||||
import * as Subscription from '@userActions/Subscription'; | ||||||||||
import ONYXKEYS from '@src/ONYXKEYS'; | ||||||||||
import type SCREENS from '@src/SCREENS'; | ||||||||||
|
@@ -29,6 +31,9 @@ function SubscriptionSizePage({route}: SubscriptionSizePageProps) { | |||||||||
const onFinished = () => { | ||||||||||
Subscription.updateSubscriptionSize(subscriptionSizeFormDraft ? Number(subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE]) : 0, privateSubscription?.userCount ?? 0); | ||||||||||
Navigation.goBack(); | ||||||||||
InteractionManager.runAfterInteractions(() => { | ||||||||||
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM); | ||||||||||
}); | ||||||||||
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.
Suggested change
|
||||||||||
}; | ||||||||||
|
||||||||||
const {componentToRender: SubStep, screenIndex, nextScreen, prevScreen, moveTo} = useSubStep({bodyContent, startFrom, onFinished}); | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -23,8 +23,9 @@ function Confirmation({onNext, isEditing}: ConfirmationProps) { | |||||||
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION); | ||||||||
const [subscriptionSizeFormDraft] = useOnyx(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM_DRAFT); | ||||||||
const subscriptionRenewalDate = getNewSubscriptionRenewalDate(); | ||||||||
const subscriptionSizeDraft = subscriptionSizeFormDraft ? Number(subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE]) : 0; | ||||||||
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.
Suggested change
|
||||||||
|
||||||||
const isTryingToIncreaseSubscriptionSize = (subscriptionSizeFormDraft ? Number(subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE]) : 0) > (privateSubscription?.userCount ?? 0); | ||||||||
const isTryingToIncreaseSubscriptionSize = subscriptionSizeDraft > (privateSubscription?.userCount ?? 0); | ||||||||
const canChangeSubscriptionSize = (account?.canDowngrade ?? false) || (isTryingToIncreaseSubscriptionSize && isEditing); | ||||||||
const formattedSubscriptionEndDate = formatSubscriptionEndDate(privateSubscription?.endDate); | ||||||||
|
||||||||
|
@@ -41,7 +42,7 @@ function Confirmation({onNext, isEditing}: ConfirmationProps) { | |||||||
<MenuItemWithTopDescription | ||||||||
interactive={false} | ||||||||
description={translate('subscription.subscriptionSize.subscriptionSize')} | ||||||||
title={translate('subscription.subscriptionSize.activeMembers', {size: subscriptionSizeFormDraft ? subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE] : 0})} | ||||||||
title={translate('subscription.subscriptionSize.activeMembers', {size: subscriptionSizeDraft})} | ||||||||
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.
Suggested change
|
||||||||
/> | ||||||||
<MenuItemWithTopDescription | ||||||||
interactive={false} | ||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Krishna2323 This is not needed; we have already a code for cleaning the draft values when the form is closed.
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.
calling
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM);
without interaction manager will show0
in the input before animation starts.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.
why do we have to clear the drafvalues here?
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.
If not cleared, we will see value with decimals when we visit the form again.
App/src/components/Form/FormProvider.tsx
Lines 243 to 244 in e24cf4d
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.
@Krishna2323 could you please share steps to replicate this bug?
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.
@Krishna2323 Here is the diff code
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.
Friendly bump @Krishna2323.
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.
@fedirjh, I will update in few moments, I still think this won't work correctly, in offline mode the input won't be cleared and if we clear it in optimistic data, the transition issue will occur but I will test and let you know.
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.
@fedirjh, the subscription size is cleared before the animation happens, its hard to catch on web but I think it can cause regression on slower mWeb/native devices.
web_chrome.mp4
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.
@Krishna2323 I see your point, it's not really that noticeable. I am still against using the
InteractionManager.runAfterInteractions
for web because it just usessetTimout
under the hood and it looks hacky. One final try is to fall back toprivateSubscription.userCount
when the form draft is cleared; I will suggest the changes shortly.