-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Subscription size - Decimal point can be inserted and not removed on the confirmation page. #44507
Conversation
…d on the confirmation page. Signed-off-by: Krishna Gupta <[email protected]>
InteractionManager.runAfterInteractions(() => { | ||
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM); | ||
}); |
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 show 0
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
} else if (inputProps.shouldSaveDraft && draftValues?.[inputID] !== undefined && inputValues[inputID] === undefined) { | |
inputValues[inputID] = draftValues[inputID]; |
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.
@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
diff --git a/src/libs/actions/Subscription.ts b/src/libs/actions/Subscription.ts
index beed2b1b29..4bd52bc8e8 100644
--- a/src/libs/actions/Subscription.ts
+++ b/src/libs/actions/Subscription.ts
@@ -7,6 +7,7 @@ import CONST from '@src/CONST';
import type {FeedbackSurveyOptionID, SubscriptionType} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxData} from '@src/types/onyx/Request';
+import INPUT_IDS from '@src/types/form/SubscriptionSizeForm';
/**
* Fetches data when the user opens the SubscriptionSettingsPage
@@ -190,6 +191,11 @@ function updateSubscriptionSize(newSubscriptionSize: number, currentSubscription
},
},
},
+ {
+ onyxMethod: Onyx.METHOD.MERGE,
+ key: ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM_DRAFT,
+ value: null,
+ },
],
successData: [
{
@@ -217,6 +223,13 @@ function updateSubscriptionSize(newSubscriptionSize: number, currentSubscription
},
},
},
+ {
+ onyxMethod: Onyx.METHOD.MERGE,
+ key: ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM_DRAFT,
+ value: {
+ [INPUT_IDS.SUBSCRIPTION_SIZE]: String(newSubscriptionSize),
+ },
+ },
],
};
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 uses setTimout
under the hood and it looks hacky. One final try is to fall back to privateSubscription.userCount
when the form draft is cleared; I will suggest the changes shortly.
src/pages/settings/Subscription/SubscriptionSize/substeps/Confirmation.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Krishna Gupta <[email protected]>
Reviewer Checklist
Screenshots/VideosAndroid: mWeb ChromeCleanShot.2024-07-01.at.01.41.30.mp4iOS: mWeb SafariCleanShot.2024-07-01.at.01.23.36.mp4MacOS: Chrome / SafariCleanShot.2024-07-01.at.01.17.25.mp4MacOS: DesktopCleanShot.2024-07-01.at.01.43.45.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.
Let's avoid the using InteractionManager.runAfterInteractions
per https://github.com/Expensify/App/pull/44507/files#r1674425940
InteractionManager.runAfterInteractions(() => { | ||
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM); | ||
}); |
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.
InteractionManager.runAfterInteractions(() => { | |
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM); | |
}); | |
FormActions.clearDraftValues(ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
const subscriptionSizeDraft = subscriptionSizeFormDraft ? Number(subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE]) : 0; | |
const subscriptionSizeDraft = subscriptionSizeFormDraft ? Number(subscriptionSizeFormDraft[INPUT_IDS.SUBSCRIPTION_SIZE]) : 0; | |
const subscriptionSize = subscriptionSizeDraft || (privateSubscription?.userCount ?? 0); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
title={translate('subscription.subscriptionSize.activeMembers', {size: subscriptionSizeDraft})} | |
title={translate('subscription.subscriptionSize.activeMembers', {size: subscriptionSize})} |
Signed-off-by: krishna2323 <[email protected]>
@fedirjh, changes works well, thanks for the help🙏🏻, code updated. |
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.
Looks good and tests well
@AndrewGable bump for a review. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/AndrewGable in version: 9.0.11-0 🚀
|
🚀 Cherry-picked to staging by https://github.com/francoisl in version: 9.0.11-2 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.11-5 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.12-0 🚀
|
Details
Fixed Issues
$ #43796
PROPOSAL: #43796 (comment)
Tests
Note: Subscription Size page is only available on web/mWeb and desktop app
/settings/subscription/subscription-size
Offline tests
Note: Subscription Size page is only available on web/mWeb and desktop app
/settings/subscription/subscription-size
QA Steps
Note: Subscription Size page is only available on web/mWeb and desktop app
/settings/subscription/subscription-size
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android_native.mp4
Android: mWeb Chrome
android_chrome.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4