Skip to content
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

[$500] Chat - Pressing ESC closes the video preview modal instead of Download and Playback modal #36902

Closed
2 of 6 tasks
kbecciv opened this issue Feb 20, 2024 · 27 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Feb 20, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v1.4.43-2
Reproducible in staging?: y
Reproducible in production?: new feature
Issue reported by: Applause - Internal Team

Action Performed:

  1. Click on "Add attachment"
  2. Upload a video
  3. Click on three dot then press ESC

Expected Result:

Pressing ESC should not close the video preview modal, it should only close the Download and Playback modal

Actual Result:

Pressing ESC closes the video preview modal instead of Download and Playback modal

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6385631_1708430465452.2024-02-20_14-37-14__1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01cb3dff1b828d5004
  • Upwork Job ID: 1759958094772105216
  • Last Price Increase: 2024-02-20
  • Automatic offers:
    • jjcoffee | Reviewer | 0
    • bernhardoj | Contributor | 0
@kbecciv kbecciv added DeployBlockerCash This issue or pull request should block deployment External Added to denote the issue can be worked on by a contributor labels Feb 20, 2024
@melvin-bot melvin-bot bot changed the title Chat - Pressing ESC closes the video preview modal instead of Download and Playback modal [$500] Chat - Pressing ESC closes the video preview modal instead of Download and Playback modal Feb 20, 2024
Copy link

melvin-bot bot commented Feb 20, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01cb3dff1b828d5004

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 20, 2024
Copy link

melvin-bot bot commented Feb 20, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

@melvin-bot melvin-bot bot added the Daily KSv2 label Feb 20, 2024
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Feb 20, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Feb 20, 2024

Triggered auto assignment to @Julesssss (Engineering), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@Julesssss Julesssss added Daily KSv2 Improvement Item broken or needs improvement. and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Feb 20, 2024
@Julesssss
Copy link
Contributor

Edge case, not a blocker

@hkopser99
Copy link
Contributor

Hey @Julesssss if this is an edge case can we still review/submit proposals or will this be assigned down the road if/when it becomes a higher priority?

@Julesssss
Copy link
Contributor

@hkopser99 yeah, my comment was just to remove the high priority label. THis will be made external 👍

@Julesssss Julesssss added the Bug Something is broken. Auto assigns a BugZero manager. label Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@Julesssss Julesssss added External Added to denote the issue can be worked on by a contributor and removed External Added to denote the issue can be worked on by a contributor labels Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

Current assignee @jjcoffee is eligible for the External assigner, not assigning anyone new.

@hkopser99
Copy link
Contributor

hkopser99 commented Feb 21, 2024

Hi @jjcoffee

Proposal:

Please re-state the problem that we are trying to solve in this issue:

When a user presses esc instead of ending the video player preview during the video attachment upload flow, it escapes from the attachment upload completely.

What is the root cause of that problem?: Default escape key behavior escapes from the video preview modal and prevents user from proceeding with uploading the attachment rather than simply pausing the video preview.

What changes do you think we should make in order to solve the problem?

In BaseVideoPlayer.js I would implement logic to recognize an esc key press, override default behavior, and use a callback that would call pauseVideo() if isVideoPlaying is set to true.

What alternative solutions did you explore? (Optional):

Given existing functionality, this seems like the smoothest solution unless additional functionality is desired when a use presses esc on desktop browsers or MacOS App.

@bernhardoj
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Pressing ESC closes both the video player popover and the video player preview modal.

What is the root cause of that problem?

Both video player preview modal (BaseModal) and video player popover (PopoverWithoutOverlay) catch the ESC event. PopoverWithoutOverlay listens for keydown, while BaseModal (react-native-modal) listens for keyup event.

useEffect(() => {
const listener = (e: KeyboardEvent) => {
if (e.key !== 'Escape') {
return;
}
closePopover();
};
document.addEventListener('keydown', listener, true);
return () => {
document.removeEventListener('keydown', listener, true);
};
}, [closePopover]);

+ this.handleEscape = (e) => {
+ if (e.key === 'Escape') {
+ if (this.onBackButtonPress() === true) {
+ e.stopImmediatePropagation();
+ }
+ }
+ };
this.shouldPropagateSwipe = (evt, gestureState) => {
return typeof this.props.propagateSwipe === 'function'
? this.props.propagateSwipe(evt, gestureState)
@@ -453,10 +460,18 @@ export class ReactNativeModal extends React.Component {
if (this.state.isVisible) {
this.open();
}
+ if (Platform.OS === 'web') {
+ document?.body?.addEventListener?.('keyup', this.handleEscape, true);
+ return;
+ }

In react-native-modal, we prevent the propagation when a modal handles the ESC, but we didn't do that for PopoverWithoutOverlay, so the event is propagated to all views.

What changes do you think we should make in order to solve the problem?

We should follow the same pattern we already have in react-native-modal, that is to stop the propagation.

if (closePopover()) {
    e.stopImmediatePropagation();
}

closePopover will return true if it passes the early return.

const closePopover = useCallback((anchorRef?: RefObject<View | HTMLElement>) => {
if (!activePopoverRef.current || (anchorRef && anchorRef !== activePopoverRef.current.anchorRef)) {
return;
}
activePopoverRef.current.close();
activePopoverRef.current = null;
setIsOpen(false);
}, []);

However, this still won't work because PopoverWithoutOverlay and BaseModal listen for different events (mentioned on the root cause). We should decide whether we want to use keyup or keydown.

What alternative solutions did you explore? (Optional)

Use BaseModal instead of PopoverWithoutOverlay by removing withoutOverlay.

return (
<PopoverMenu
onClose={hidePopover}
onItemSelected={hidePopover}
isVisible={isPopoverVisible}
anchorPosition={anchorPosition}
menuItems={menuItems}
withoutOverlay
/>
);

@jjcoffee
Copy link
Contributor

Happy that @bernhardoj's proposal identifies the correct root cause and that the solution fits decently with it. I think it makes sense to switch to keyup to keep things consistent with the BaseModal, unless anyone has reasons to believe keydown is better?

@hkopser99 Thanks for your proposal! Unfortunately it's lacking somewhat in details, and the solution proposed doesn't match the expected result (we don't want to pause the video). Please also make sure to use the proposal template exactly as it appears (don't strip the formatting), as this makes it easier for everyone to parse your proposal quickly. 🙏

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Feb 21, 2024

Current assignee @Julesssss is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@hkopser99
Copy link
Contributor

@jjcoffee Thanks for reviewing and the feedback. I will do better next time and will use the exact proposal template.

@Christinadobrzyn
Copy link
Contributor

@Julesssss would you be able to review the decision here - #36902 (comment) when you have a moment

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 22, 2024
@Julesssss
Copy link
Contributor

Yep, I missed this somehow. Done!

Copy link

melvin-bot bot commented Feb 22, 2024

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Feb 22, 2024

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready

cc: @jjcoffee

@Rajat1120
Copy link

Rajat1120 commented Feb 23, 2024

Now, it doesn't even show the preview of the video

Screen.Recording.2024-02-23.at.10.27.24.PM.mp4

Copy link

melvin-bot bot commented Feb 23, 2024

📣 @Rajat1120! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Rajat1120
Copy link

Contributor details
Your Expensify account email: rajatkumarsaha254@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/rajatkumar16

Copy link

melvin-bot bot commented Feb 23, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@jjcoffee
Copy link
Contributor

This hit production 2 weeks ago.

@jjcoffee
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A - this was a latent bug in PopoverWithoutOverlay that the video player implementation brought to light
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug. Yes
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Proposal

Desktop only:

  1. Open any chat
  2. Add a new video attachment. Verify the attachment preview is shown.
  3. On the video player control, press the three dots button. Verify the video player popover is shown
  4. Press ESC
  5. Verify the video player popover is closed
  6. Press ESC again
  7. Verify the attachment preview is closed

Do we agree 👍 or 👎

@jjcoffee
Copy link
Contributor

@Christinadobrzyn Checklist complete! This one's due payment, the automation just looks to have failed.

@Christinadobrzyn
Copy link
Contributor

Ah thanks for moving this along @jjcoffee

Payouts due:

Contributor: $500 @bernhardoj (paid in Upwork - https://www.upwork.com/nx/wm/workroom/36436009/overview)
Contributor+: $500 @jjcoffee (paid in Upwork - https://www.upwork.com/nx/wm/workroom/36436097/overview)

Upwork job is here.

Regression test: https://github.com/Expensify/Expensify/issues/378294

Closing! let me know if I missed anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants