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

[HOLD for payment 2024-09-03][$250] iOS - Attachment - I can to switch to another attachment in PDF zoomed state #47805

Closed
1 of 6 tasks
IuliiaHerets opened this issue Aug 21, 2024 · 21 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 21, 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: 9.0.23-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4879183&group_by=cases:section_id&group_id=292107&group_order=asc
Issue reported by: Applause Internal Team

Action Performed:

  1. Open the app
  2. Log in with any account
  3. Open any 1:1 chat
  4. Send any photo attachment
  5. Send any PDF attachment
  6. Send any photo attachment
  7. Open the PDF
  8. Switch to the image on the right after the PDF finished loading
  9. Switch back to the PDF
  10. Zoom in on the PDF with the pinch method
  11. Switch to the image on the right while the PDF is still zoomed

Expected Result:

I shouldn't be able to to switch to another attachment in PDF zoomed state.

Actual Result:

I can to switch to another attachment in PDF zoomed state after swiping to an image and back to the PDF.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6578108_1724244156588.JCEQ1898.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010723f9a2c0dc6d78
  • Upwork Job ID: 1827109849447510261
  • Last Price Increase: 2024-08-23
Issue OwnerCurrent Issue Owner: @s77rt
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 21, 2024
Copy link

melvin-bot bot commented Aug 21, 2024

Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@IuliiaHerets
Copy link
Author

We think that this bug might be related to #vip-vsb

@IuliiaHerets
Copy link
Author

@johncschuster FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@bernhardoj
Copy link
Contributor

Proposal

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

We can swipe between attachment even though the PDF or image is zoomed in.

What is the root cause of that problem?

When the attachment scale is changed, we call the carousel pager onScaleChanged which will disable the scrolling/swiping (isScrollEnabled.value).

if (isUsedInCarousel && attachmentCarouselPagerContext) {
attachmentCarouselPagerContext.onScaleChanged(newScale);
}

const handleScaleChange = useCallback(
(newScale: number) => {
if (newScale === scale.current) {
return;
}
scale.current = newScale;
const newIsScrollEnabled = newScale === 1;
if (isScrollEnabled.value === newIsScrollEnabled) {
return;
}
// eslint-disable-next-line react-compiler/react-compiler
isScrollEnabled.value = newIsScrollEnabled;
onRequestToggleArrows(newIsScrollEnabled);
},
[isScrollEnabled, onRequestToggleArrows],

const animatedProps = useAnimatedProps(() => ({
scrollEnabled: isScrollEnabled.value,
}));

But it doesn't work for both PDF and image. For the PDF, we only call the scale change callback if isUsedInCarousel is true, but we never pass the props.

if (isUsedInCarousel && attachmentCarouselPagerContext) {
attachmentCarouselPagerContext.onScaleChanged(newScale);
}

For both image and PDF, even though the scale change callback is called, the scroll is never disabled because the isScrollEnabled.value here

const animatedProps = useAnimatedProps(() => ({
scrollEnabled: isScrollEnabled.value,
}));

is coming from the local shared value.

const isScrollEnabled = useSharedValue(true);

But the scale change callback changes the useCarouselContextEvents shared value.

function useCarouselContextEvents(setShouldShowArrows: (show?: SetStateAction<boolean>) => void) {
const scale = useRef(1);
const isScrollEnabled = useSharedValue(true);

This happens after #43620.

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

In pdf attachment component, we can check for pagerRef context, just like we did with image.

// When a pdf is shown in a carousel, we want to disable the pager scroll when the pdf is zoomed in
if (isUsedInCarousel && attachmentCarouselPagerContext) {
attachmentCarouselPagerContext.onScaleChanged(newScale);
}

if (!!attachmentCarouselPagerContext?.pagerRef) {

isUsedInCarousel: !!attachmentCarouselPagerContext.pagerRef,

To fix the double isScrollEnabled, we can remove isScrollEnabled from AttachmentCarouselPager/Pager,

const isScrollEnabled = useSharedValue(true);

then use it from useCarouselContextEvents.

const {handleTap, handleScaleChange, isScrollEnabled} = useCarouselContextEvents(setShouldShowArrows);

useCarouselContextEvents will return the isScrollEnabled.

const isScrollEnabled = useSharedValue(true);

return {handleTap, handleScaleChange, scale};

return {handleTap, handleScaleChange, scale, isScrollEnabled};

@melvin-bot melvin-bot bot added the Overdue label Aug 23, 2024
@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Aug 23, 2024
Copy link

melvin-bot bot commented Aug 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~010723f9a2c0dc6d78

@melvin-bot melvin-bot bot changed the title iOS - Attachment - I can to switch to another attachment in PDF zoomed state [$250] iOS - Attachment - I can to switch to another attachment in PDF zoomed state Aug 23, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 23, 2024
Copy link

melvin-bot bot commented Aug 23, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Aug 23, 2024
@s77rt
Copy link
Contributor

s77rt commented Aug 24, 2024

Not reproducible

Screen.Recording.2024-08-24.at.8.34.49.PM.mov

@bernhardoj
Copy link
Contributor

Hmm, your video shows that it's reproducible.

Expected Result:
I shouldn't be able to to switch to another attachment in PDF zoomed state.

Actual Result:
I can to switch to another attachment in PDF zoomed state after swiping to an image and back to the PDF.

@s77rt
Copy link
Contributor

s77rt commented Aug 25, 2024

@bernhardoj Oh I misunderstood the issue, you are right! Your RCA makes sense but regarding the solution:

we only call the scale change callback if isUsedInCarousel is true, but we never pass the props.

Shouldn't we just pass the prop instead of checking against !!attachmentCarouselPagerContext.pagerRef (DRY)

(Using isScrollEnabled from useCarouselContextEvents is 👍)

@bernhardoj
Copy link
Contributor

Shouldn't we just pass the prop instead of checking against !!attachmentCarouselPagerContext.pagerRef

We already have the information from attachmentCarouselPagerContext.pagerRef (which we already use in image component, Lightbox), so relying on another source (isUsedInCarousel) won't make it DRY I guess.

@s77rt
Copy link
Contributor

s77rt commented Aug 25, 2024

@bernhardoj For this case the prop is always passed as true from CarouselItem to AttachmentView and since it's available in AttachmentView we should just pass it down to the AttachmentViewPdf

@bernhardoj
Copy link
Contributor

We can always remove isUsedInCarousel but we can't remove thepagerRef. Instead of doing props drilling while we already have the information from a context, I prefer to get it from the context.

@s77rt
Copy link
Contributor

s77rt commented Aug 26, 2024

@bernhardoj Removing isUsedInCarousel sounds good to me. As long as we keep only one source of truth.

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Aug 26, 2024

Triggered auto assignment to @arosiclair, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 26, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 26, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @s77rt

@johncschuster johncschuster changed the title [$250] iOS - Attachment - I can to switch to another attachment in PDF zoomed state [HOLD for payment 2024-09-03][$250] iOS - Attachment - I can to switch to another attachment in PDF zoomed state Sep 10, 2024
@johncschuster
Copy link
Contributor

Payment Summary:

Contributor: @bernhardoj owed $250 via NewDot
Contributor+: @s77rt owed $250 via NewDot

@bernhardoj / @s77rt do you feel this requires regression test steps? If so, can you please provide them? Thank you!

@s77rt
Copy link
Contributor

s77rt commented Sep 11, 2024

@johncschuster This already has a regression test.

@johncschuster
Copy link
Contributor

Awesome. Thanks, @s77rt! In that case, we're all done here. Please make your manual requests!

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @s77rt

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
No open projects
Status: No status
Development

No branches or pull requests

6 participants