-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 "Closing split bill doesn't refocus on composer" on web/desktop #12031
Conversation
@Luke9389 @aimane-chnaif I was just about to test and while checking the code locally, I think we can further refactor this. We have What do you folks think? |
I agree |
@aimane-chnaif Can you implement the changes requested? cc - @Luke9389 |
@mananjadhav ready for review |
thanks @aimane-chnaif. Will need 1-2 days to test this as it'll required a good amount of regression suite to test. |
Thanks for the changes and patience on this one @aimane-chnaif. Changes look good and test well. I agree with your comment that for mobile devices (app and mweb) we don't want to refocus as it'll popup the keyboard. @Luke9389 All yours 🎀 👀 🎀
ScreenshotsWebweb-refocus-composer.movMobile Web - Chromemweb-chrome-dont-refocus-composer.movMobile Web - Safarimweb-safari-dont-refocus-composer.movDesktopdesktop-refocus-composer.moviOSios-dont-refocus-composer.movAndroidandroid-dont-refocus-composer.mov |
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'll be coming around to this one tomorrow. Thanks for the changes.
@Luke9389 Quick bump on this one |
@Luke9389 did you get a chance to look at this PR? |
Oh man, missed it. Thanks for the bump(s) |
src/components/PopoverMenu/index.js
Outdated
this.onMenuHide = () => { | ||
item.onSelected(); | ||
|
||
// Clean up: open and immediately cancel should not re-trigger the last action |
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.
Where do we stand with this? Have we tested that?
I know this came from the previous code but now that we're changing this component we should be sure it works in all contexts.
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 code is inside selectItem(item)
to get item
and call item.onSelected()
after modal fully closed, which was selected before triggering modal close.
But I suggest to refactor this to use variable instead of function inside function:
constructor(props) {
super(props);
this.state = {
focusedIndex: -1,
};
this.updateFocusedIndex = this.updateFocusedIndex.bind(this);
this.resetFocusAndHideModal = this.resetFocusAndHideModal.bind(this);
this.removeKeyboardListener = this.removeKeyboardListener.bind(this);
this.attachKeyboardListener = this.attachKeyboardListener.bind(this);
- this.onMenuHide = () => {};
+ this.selectedItem = null;
}
- /**
- * Set the item's `onSelected` action to fire after the menu popup closes
- * @param {{onSelected: function}} item
- */
selectItem(item) {
- this.onMenuHide = () => {
- item.onSelected();
-
- // Clean up: open and immediately cancel should not re-trigger the last action
- this.onMenuHide = () => {};
- };
+ this.selectedItem = item;
this.props.onItemSelected(item);
}
resetFocusAndHideModal() {
this.updateFocusedIndex(-1); // Reset the focusedIndex on modal hide
this.removeKeyboardListener();
- this.onMenuHide();
+ if (this.selectedItem) {
+ this.selectedItem.onSelected();
+ this.selectedItem = null;
+ }
}
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 I like that change. Go ahead and commit it and test it out!
src/components/PopoverMenu/index.js
Outdated
/** | ||
* @param {Number} index | ||
*/ | ||
updateFocusedIndex(index) { | ||
this.setState({focusedIndex: index}); | ||
} |
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 don't think this should be it's own function. Just use setState when you need it.
@Luke9389 ready for review |
@aimane-chnaif did you test this on all platforms (multiple pop-overs, not just the bill split one)? |
yes, tested all Popover modals and accessibility |
@Luke9389 @aimane-chnaif Is there anything pending here? Then I can retest with the latest changes and update the checklist again. |
yes please. tests well on my side |
I've tested again with the updated changes. Thanks for the changes @aimane-chnaif. @Luke9389 All yours. 🎀 👀 🎀 Reviewer Checklist
ScreenshotsWebweb-refocus-composer.movMobile Web - Chromemweb-chrome-refocus-compoer.movMobile Web - Safarimweb-safari-refocus-compoer.movDesktopdesktop-refocus-composer.moviOSios-refocus-compoer.movAndroidandroid-refocus-composer.mov |
@Luke9389 Did you get a chance to look at the previous comments? |
@Luke9389 This PR is blocked by your review and approval. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Hi this PR has been linked to a regression here: #13435 I think since this is a lower level change more care could have been applied to test all the existing popovers. In fact, that is what this checkbox is asking us to do.
@mananjadhav @aimane-chnaif please keep this in mind in the future. If we are making changes to something that is used multiple places it's a good idea to quickly check all the usages of that thing, thanks! |
🚀 Deployed to production by @chiragsalian in version: 1.2.38-6 🚀
|
Details
In PopoverMenu component,
props.onItemSelected(item);
should be called first. And thenitem.onSelected();
should be called after onModalHide callback.This is already done in native side: https://github.com/Expensify/App/blob/main/src/components/PopoverMenu/index.native.js
We no longer need platform specific handling for this component.
So remove current index.js and rename index.native.js to index.js
Fixed Issues
$ #10888
PROPOSAL: #10888 (comment)
Tests
NOTE: It's intended behavior to prevent focus on touchable devices (native, mWeb) after navigating back from modal screens. reference:
App/src/pages/home/report/ReportActionCompose.js
Lines 168 to 174 in fbf0334
QA Steps
PR Review Checklist
PR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesWaiting 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)/** comment above it */
this
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)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting 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
have been tested & I retested again)/** comment above it */
this
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
web.mov
Mobile Web - Chrome
mchrome.mp4
Mobile Web - Safari
msafari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mp4