-
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
Only subscribe shortcuts when modal is open #18425
Only subscribe shortcuts when modal is open #18425
Conversation
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.
Some slight suggestions
- Move the subscribe(s) block to a new method
- Call that new method on component did mount as well if we initially rendered the modal as open
- Call the new method on component did update (as you currently do)
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.
Testing now but looks good
if (this.unsubscribeArrowDownKey) { | ||
this.unsubscribeArrowDownKey(); | ||
this.unsubscribeArrowDownKey = undefined; | ||
} |
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, but this makes me wonder if we should be hooking these into the render of something like the modal content. Seems kind of weird to have these listeners all getting created or removed as a side effect of the prop changing instead of the mount/unmount. But maybe we can do something about it 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.
Agreed, I thought of creating a class component that would be rendered inside the modal only when prop.isShortcutsModalOpen = true
. That way we could have used mount/unmount which is a bit cleaner I think.
I didn't continue because we are supposed to migrate everything to hooks, so it would have to be redone anyway.
Just tested, LGTM. |
Since this is a deploy blocker I think we should follow up with anything like this later:
|
I updated the code to handle this: #18425 (review) If you refresh with the modal open, the modal appears open and the shortcuts were not subscribed. |
|
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
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! 🚀
I'm having trouble testing in the android simulator and IOS simulator. Does that matter? ping @marcaaron if you can review the latest changes 🙏 |
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.
Just one small style comment as we prefer underscore to array methods still.
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
Updated the |
…ng-s77rt-proposal Only subscribe shortcuts when modal is open (cherry picked from commit dc644fd)
…-18425 🍒 Cherry pick PR #18425 to staging 🍒
🚀 Cherry-picked to staging by https://github.com/aldo-expensify in version: 1.3.10-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Cherry-picked to staging by https://github.com/AndrewGable in version: 1.3.28-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/AndrewGable in version: 1.3.28-5 🚀
|
Details
The shortcut modal subscribe some shortcuts to block them from working while its open.
The previous implementation ended up blocking some key functions in the composer because we end up calling this
event.preventDefault()
here:App/src/libs/KeyboardShortcut/bindHandlerToKeydownEvent/index.js
Lines 46 to 48 in 2437e37
Some more details: #18420 (comment)
Fixed Issues
$ #18420
PROPOSAL: Option 1 from #18420 (comment)
Tests
Follow the testing steps of this other PR: #18273
Offline tests
QA Steps
Follow the testing steps of this other PR: #18273
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)/** 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)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
Web
Screen.Recording.2023-05-04.at.11.41.14.AM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
Screen.Recording.2023-05-04.at.11.59.23.AM.mov
iOS
Android
Screen.Recording.2023-05-04.at.12.03.34.PM.mov