-
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
Block navigation shortcuts when plaid modal is loading/shown #18462
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would also work, @aldo-expensify @0xmiroslav please let me know if I should update 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.
@aldo-expensify @0xmiroslav bump ^
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, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is safety check but when does this happen?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we don't need redundant code if we 100% confirm that it's redundant
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.
Done @0xmiroslav
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: no need to define unsubscribeCallbacks
variable. set to this.subscribedKeyboardShortcuts
directly
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.
Done @0xmiroslav
@huzaifa-99 please merge main |
@0xmiroslav main merged |
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.
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 |
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.
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 + K
shortcut to create group chat, verify if this shortcut is blocked (it must be). The page url will be/settings/payments/add-bank-account
CTRL/CMD + SHIFT + K
shortcut 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 + K
shortcut to open search, verify if this shortcut is blocked (it must be). The page url will be/settings/payments/add-bank-account
CTRL/CMD + K
shortcut 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 + K
worksCTRL/CMD + K
: it should do nothingCTRL/CMD + K
works againOffline tests
Same as the "Tests" section above.
QA Steps
Same as the "Tests" section above.
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
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