Block navigation shortcuts when plaid modal is loading/shown#18462
Conversation
|
@aldo-expensify @0xmiroslav One of you needs to 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] |
|
Sry for the lint issues above. This was my first PR here with more than 10 line changes, so forgot to properly lint. Will be careful next time. |
| // block keyboard shortcuts that can navigate when plaid modal is shown | ||
| if (lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0) { | ||
| this.unblockKeyboardShortcuts(); | ||
| } else { | ||
| this.blockKeyboardShortcuts(); | ||
| } |
There was a problem hiding this comment.
I have some preference for subscribing the keyboard shortcuts in componentDidMount and setting the parameter shouldBubble to () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0 so it allows the default shortcuts to work when we have the bank accounts.
I just find it slightly easier to understand when this can happen if it is in componentDidMount and componentWillUnmount compared to componentDidUpdate
@0xmiroslav thoughts?
There was a problem hiding this comment.
That would also work, @aldo-expensify @0xmiroslav please let me know if I should update it.
There was a problem hiding this comment.
yes, it's better solution. Thanks for suggestion
@huzaifa-99 let's do that!
| shortcut.descriptionKey, | ||
| shortcut.modifiers, | ||
| false, | ||
| () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // stop bubbling when there are bank accounts |
There was a problem hiding this comment.
Is this correct comment?
There was a problem hiding this comment.
Nice catch, it should be 'start' (fixed). Thanks for spotting @0xmiroslav
| // return early if shortcuts already blocked | ||
| if (this.subscribedKeyboardShortcuts.length > 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This is safety check but when does this happen?
There was a problem hiding this comment.
Since we are now subscribing in the componentDidMount, this check would not be triggered. Its safe to remove, @0xmiroslav should I do that?
There was a problem hiding this comment.
yes, we don't need redundant code if we 100% confirm that it's redundant
| const unsubscribeCallbacks = _.map( | ||
| shortcutsToBlock, | ||
| shortcut => KeyboardShortcut.subscribe( | ||
| shortcut.shortcutKey, | ||
| () => {}, // do nothing | ||
| shortcut.descriptionKey, | ||
| shortcut.modifiers, | ||
| false, | ||
| () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // start bubbling when there are bank accounts | ||
| ), | ||
| ); | ||
| this.subscribedKeyboardShortcuts = unsubscribeCallbacks; |
There was a problem hiding this comment.
NAB: no need to define unsubscribeCallbacks variable. set to this.subscribedKeyboardShortcuts directly
|
@huzaifa-99 please merge main |
|
@0xmiroslav main merged |
0xmiroslav
left a comment
There was a problem hiding this comment.
Looks good. Checklisting
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop1.movdesktop2.moviOSios.movAndroidandroid.mov |
|
@aldo-expensify over to you! |
|
@huzaifa-99 I think you may need to pull |
aldo-expensify
left a comment
There was a problem hiding this comment.
Worked well for me.
Added testing instructions for the VBBA flow.
@huzaifa-99 , you will need to update from main again to fix the tests.
|
@aldo-expensify Main merged. Tests are also passing |
|
Thanks @huzaifa-99 ! |
|
✋ 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/aldo-expensify in version: 1.3.13-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.13-5 🚀
|
Details
Fixed Issues
$ #17598
PROPOSAL: #17598 (comment)
Tests
Verify if Group creation shortcut is blocked when there is no plaid modal shown
CTRL/CMD + SHIFT + Kshortcut to create group chat, verify if this shortcut is blocked (it must be). The page url will be/settings/payments/add-bank-accountCTRL/CMD + SHIFT + Kshortcut again, verify if it works (it must work this time).Verify if search shortcut is blocked when there is no plaid modal shown
CTRL/CMD + Kshortcut to open search, verify if this shortcut is blocked (it must be). The page url will be/settings/payments/add-bank-accountCTRL/CMD + Kshortcut again, verify if it works (it must work this time).Verify if Group creation shortcut is blocked when plaid modal is loading in VBBA flow
CTRL/CMD + KworksCTRL/CMD + K: it should do nothingCTRL/CMD + Kworks againOffline tests
Same as the "Tests" section above.
QA Steps
Same as the "Tests" section above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Chrome
Desktop.Chrome.-.compressed.mp4
Safari
Desktop.Safari.-.compressed.mp4
Mobile Web - Chrome
17598.mp4
Mobile Web - Safari
IOS.Safari.mp4
Desktop
Mac.Desktop.-.compressed.mp4
iOS
Screen.Recording.2023-05-05.at.6.33.49.AM.mov
Android
2.mp4