-
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 compose box resurfacing issue #9060
Conversation
Found a solution for web and mobile web (the edit comment feature needs improvement there) and still need to test iOS/Android. |
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!
Testing... |
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.
BUG: Composer stays hidden on switching the chats.
Steps:
- Open any chat on Android.
- Edit any message.
- Click hardware back button.
- Open any other chat.
- No Composer.
I was doing this #8255 to solve it.
onPress={this.publishDraft} | ||
onPress={() => { | ||
this.publishDraft(); | ||
toggleReportActionComposeView(true, VirtualKeyboard.shouldAssumeIsOpen()); |
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.
This is indirectly happening on publishDraft => deleteDraft
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'm not following. What is happening exactly?
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 meant that this is already being called in publishDraft
. So this call is a duplicate.
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.
Got it tried to remove it. Let me know if you see any issues? Tested Android and it worked well.
@@ -210,6 +210,14 @@ class ReportActionItemMessageEdit extends React.Component { | |||
ReportScrollManager.scrollToIndex({animated: true, index: this.props.index}, true); | |||
toggleReportActionComposeView(false, VirtualKeyboard.shouldAssumeIsOpen()); | |||
}} | |||
onBlur={(event) => { | |||
// Return to prevent re-render when save button is pressed which cancels the onPress event by re-rendering | |||
if (lodashGet(event, 'nativeEvent.relatedTarget.id') === 'saveButton') { |
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.
Should we move saveButton
to CONST? may be not. As this would be local to the component.
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.
Yeah, maybe it can be private to this file, but agree makes sense as a variable.
@parasharrajat Thanks! And that's interesting so... the hardware back button is not causing the input to lose focus? I'll do some testing now and see. |
Ah ok so revealing the sidebar does not blur the input. The solution you shared only works if the |
Sounds like a potential solution. I will test more on other platforms to see if there are other such cases. |
Please merge main. There are conflicts. |
Updated. Best solution I could come up with is to reset the composer whenever we set the currently viewed reportID. Which happens whenever we mount a new report screen or update the reportID. |
Thanks,I have fixed my Mac. I will review this shortly and we can close this. |
This happening as there is no back handler for mWeb like native. Pressing the back button navigates the page back to previous history item. As the url is always
|
package-lock.json
Outdated
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", | ||
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", |
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.
This is strange change. I think you need to update your npm v6 to latest minor version.
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?
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.
This is unnecessary change for this PR. I also got the same in one of the PR and then upgrading to latest v6 of npm fixed it.
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 hmm looks like someone already updated expensify-common
then we don't need it.
Yes am aware of an open issue in I think it could also have to do with the
That all has to be designed and researched though and probably not a near-term priority. |
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.
Rest changes looking good to me. Thanks for fixing the issue.
I agree, the back handler issue needs a proper discussion and analysis.
Reiterating issues that we ignored on this PR:
- ScrollToBottom does not work on mWeb.
cc: @Beamanator
Yes, I think scrolling to the comment will not work until we solve the same issues we are struggling with here. |
@Gonals Can you give this another quick look whenever you get a chance? 🙇 |
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.
Tested well!
@Beamanator all yours! |
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.
Interesting situation happening here in Android app. Steps:
- Edit comment
- Start adding emojis
- In background, see that chats move up
- Dismiss emoji picker
- See that Report Action Compose is visible, but hides automatically
Note: I also reproduced on iOS, but the iOS simulator is much quicker and the ReportActionCompose component hides much quicker
Screen.Recording.2022-06-07.at.9.59.14.AM.mov
@@ -77,7 +78,7 @@ function isSingleEmoji(message) { | |||
* @returns {Boolean} | |||
*/ | |||
function containsOnlyEmojis(message) { | |||
const trimmedMessage = message.replace(/ /g, '').replaceAll('\n', ''); | |||
const trimmedMessage = Str.replaceAll(message.replace(/ /g, ''), '\n', ''); |
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.
NAB; If .replaceAll
is a native JS function (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll) why do we prefer using a lib for it here?
Also, .replace(/ /g, '')
is basically another .replaceAll(message, ' ', '')
so why not replace that one too?
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's poly-filled and not available on some mobile browsers
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.
Cool ya makes sense
Any thoughts on my second comment?
Also,
.replace(/ /g, '')
is basically another.replaceAll(message, ' ', '')
so why not replace that one too?
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.
Mostly added this to fix a bad crash with iOS 14 so that wasn't my priority. We could change the usages, but that doesn't stop people from making this mistake in the future. I also added an eslint rule to prevent people from using string.prototype.replaceAll
.
@@ -1,3 +1,4 @@ | |||
import lodashGet from 'lodash/get'; |
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.
NAB: Interested in using lodashGet
in some other places in this component?
Ex:
this.debouncedSaveDraft(this.props.action.message[0].html); |
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.
Not in this PR unless that code is being modified already. My usual preference is to only make the changes that are necessary.
@@ -1,6 +1,6 @@ | |||
import * as Session from '../actions/Session'; | |||
|
|||
export default (shouldShowComposeInput, isSmallScreenWidth) => { | |||
export default (shouldShowComposeInput, isSmallScreenWidth = true) => { |
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.
Thinking out loud: index.js
is for web & mobile (since we have a index.native.js
file) so... should this default to false, not small screen width?
Thought about this lib name: This isn't really "toggling" anything, is it? It's just setting Session.setShouldShowComposeInput
based on whatever is passed... Maybe it's due for a rename
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.
Sorry, I don't really understand this concern. Are you seeing a bug somewhere or something that needs to be addressed?
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.
Nope, no bug - this is related to my other 2 comments about web & desktop probably usually not being small screens, so it's weird to me that we default isSmallScreenWidth
to true
here.
Again, not a blocker & doesn't need to be changed until we see a bug somewhere so can resolve this
Also seeing this in iOS following this flow:
Screen.Recording.2022-06-07.at.10.55.24.AM.mov |
Yes, that is the expected behavior. |
Hey @Beamanator - good thoughts here and thanks for the review. Nothing is a blocker for me and it's important to get this one merged. If you are passionate about any of the concerns you had in the review I think we can create a follow up to address them. |
✋ 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 @marcaaron in version: 1.1.74-0 🚀
|
🚀 Deployed to production by @yuwenmemon in version: 1.1.74-2 🚀
|
onBlur={(event) => { | ||
// Return to prevent re-render when save/cancel button is pressed which cancels the onPress event by re-rendering | ||
if (_.contains([this.saveButtonID, this.cancelButtonID], lodashGet(event, 'nativeEvent.relatedTarget.id'))) { | ||
return; | ||
} | ||
|
||
toggleReportActionComposeView(true, VirtualKeyboard.shouldAssumeIsOpen()); | ||
}} |
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.
@marcaaron Could you please help me understand this change? It has caused an issue #9252 and I am trying to figure out what is it doing? Especially What do I need to test for this?
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.
What are you curious about exactly?
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.
Want to maybe walk me through what you think it's doing?
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.
So it is checking that if the Cancel or save button is clicked on the Editor, return, otherwise show the composer.
So do we want to show the composer on blur?
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.
IIRC, in this case we are ignoring the blur event because when we are blurring because the cancel or save button is clicked the method to toggle the composer (toggleReportActionComposeView
) would prevent the user from taking the actions. I assumed here (perhaps incorrectly) that it is related to re-rendering of the component - but the onPress
method for the buttons never seemed to run. Let me know if that helps!
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.
Got, It. Thanks.
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.
Do we want to show the composer on blur?
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.
Yes on blur and it should happen when we save changes or cancel the edit right? Can we have this conversation on whatever issue you are working on so I can get more insight into what you're trying to figure out?
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
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.
Please bring whatever conversation you'd like to have to a relevant issue.
Details
Fixed Issues
$ #9016
Tests & QA (On a mobile device or mWeb only)
PR Review Checklist
PR Reviewer Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followed/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Screenshots
Web
❌ - Change doesn't affect web
Mobile Web
Mobile web is working - but looks kind of inconsistent on iOS simulator. We should probably create some follow up issues for these bugs if they are not being worked...
2022-05-20_08-47-19.mp4
Desktop
❌ - Change doesn't affect desktop
iOS
2022-05-18_14-12-08.mp4
Android
2022-05-20_08-18-44.mp4