-
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: ensure composer not full size when onyx state missing #31602
fix: ensure composer not full size when onyx state missing #31602
Conversation
@0xmiroslav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@tgolen @0xmiroslav please note the additional fix explained above. |
src/libs/actions/Report.js
Outdated
if (!route) { | ||
return; | ||
} |
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.
Good additional fix but I am concerned this will cause another unexpected regression we don't know.
If route is falsy, it redirects to ROUTES.HOME as fallback which is fine.
Let's just fix OP 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.
It redirects after nav state hydration has already occurred here in the default report setter:
App/src/libs/Navigation/AppNavigator/ReportScreenIDSetter.js
Lines 85 to 91 in 04b5fa4
// If there is no reportID in route, try to find last accessed and use it for setParams | |
const reportID = getLastAccessedReportID(reports, !canUseDefaultRooms, policies, isFirstTimeNewExpensifyUser, lodashGet(route, 'params.openOnAdminRoom', false)); | |
// It's possible that reports aren't fully loaded yet | |
// in that case the reportID is undefined | |
if (reportID) { | |
navigation.setParams({reportID: String(reportID)}); |
I'm finding that just fixing the onyx key still leaves a flash that's too fast to catch on video, but it's observable if you try to repro with this branch. It isn't the composer size, so it's technically out of scope for this issue - happy to remove if you prefer. But resetting nav state twice, which only happens on wide screens loading the root domain with no path, is causing problems, we really shouldn't be doing it. It's covered in step 4 of the root cause in my proposal.
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.
The problem is a lot of UI conditionals hinge on whether there's a report id. When you load the root domain, the default report setter provides a report id, but then the deep link handler redirects, blowing up nav state and taking report id back to an empty string. This leaves a gap where various components are rendering when there's no report ID.
That happens earlier in the root cause before getReportID()
fails to return "null"
, and is technically a more accurate root cause.
getReportID()
handling empty report ids is just a backup to provide default values. Both fixes are accurate, and both are related. We're counting on a lot of default value handling across a lot of components to cover this, but there's no need for the double redirect in the first place.
I'm pretty confident that not only will this not cause more bugs, it will likely fix some seemingly unrelated issues.
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.
it will likely fix some seemingly unrelated issues
I'd suggest to raise this in slack with clear repro step and video of the buggy behavior and let team make create new GH
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.
Alright, I'll update the PR.
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.
I appreciate you digging into this and trying to fix the problem. I agree that it would be great to handle that in a separately scoped issue and PR. That makes everything easier to review/test/revert.
@0xmiroslav PR updated. |
@erquhart seems like your Screenshots/Videos is stopped on the way |
Another unrelated bug on android chrome: bug.mov |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@0xmiroslav desktop screen recording fixed, good catch |
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.
LGTM!
src/pages/home/ReportScreen.js
Outdated
@@ -128,7 +128,7 @@ const defaultProps = { | |||
*/ | |||
function getReportID(route) { | |||
// // The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. |
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.
// // The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. | |
// The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. |
This has been driving me nuts for weeks 😂 mind fixing it? It's also great that the null
default value completely went against the warning in the comment.
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.
Oh, also... you could maybe update the comment to explain why the 0
is outside of lodashGet()
instead of using it as the default value of lodashGet
. In fact, maybe I missed that part... why isn't the code like this?
lodashGet(route, 'params.reportID', 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.
''
is not falsy and doesn't fallback.
Similar in TS: '' ?? 0
returns ''
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.
Ah yes, that's right. Can you please add that to the comment so that others will understand that too? It's very subtle.
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.
Will do
src/pages/home/ReportScreen.js
Outdated
@@ -128,7 +128,7 @@ const defaultProps = { | |||
*/ | |||
function getReportID(route) { | |||
// // The reportID is used inside a collection key and should not be empty, as an empty reportID will result in the entire collection being returned. |
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.
Oh, also... you could maybe update the comment to explain why the 0
is outside of lodashGet()
instead of using it as the default value of lodashGet
. In fact, maybe I missed that part... why isn't the code like this?
lodashGet(route, 'params.reportID', 0)
@tgolen updated 👍 |
✋ 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/tgolen in version: 1.4.2-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.2-3 🚀
|
Details
Note: this bug only occured on Desktop and desktop web - small screens don't trigger the double redirect on root domain load that is required to reproduce this bug, as they only show the LHN on root domain load.
getReportID()
was supposed to be returning"null"
(null as a string) rather than empty strings, butlodash.get()
only uses the default value in place ofundefined
, so it was still able to return empty strings. The change here is ensuringgetReportID()
never returns an empty string. Per @toglen's request, and per the react-native-onyx readme, instead of"null"
we're returning"0"
. I'm returning0
as a string because it will need to be coerced to a string anyway, so no point in leaving that to chance and risking further bugs.I also found that, with the unexpected full size composer issue fix, a very quick flash was occuring in it's place. I confirmed that this wasn't the same bug by ensuring through logging that the key never ends with an empty string. I pointed out at least one other legitimate unintended behavior in my alternate solutions, and one of them - fixing our treatment of an empty path as a deeplink, which triggers a double redirect and was partly responsible for the current bug - made this issue disappear completely.
The additional fix only involves returning early in our deep link handler if the route is falsy.
Fixed Issues
$ #31089
PROPOSAL: #31089 (comment)
Tests
new.expensify.com
)To repeat without logging out and in again:
7. select a different report from the LHN, one that has not been loaded since last login
8. repeat steps 4-6
These steps work once per report. When the report initially loads and the bug is triggered, the bug won't reoccur in that report until the user logs out and back in (explanation below).
Offline tests
QA Steps
new.expensify.com
)To repeat without logging out and in again:
7. select a different report from the LHN, one that has not been loaded since last login
8. repeat steps 4-6
These steps work once per report. When the report initially loads and the bug is triggered, the bug won't reoccur in that report until the user logs out and back in (explanation below).
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
MacOS: Chrome / Safari
https://github.com/Expensify/App/assets/2112202/88ee8946-efbf-4f61-8221-03e85c6d9311MacOS: Desktop
https://github.com/Expensify/App/assets/2112202/b243bcde-76be-43e3-88c5-79beff91a63f