Skip to content

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

Closed

Description

@IuliiaHerets

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 21, 2024
  2. melvin-bot commented on Aug 21, 2024

    @melvin-bot

    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.

  3. IuliiaHerets commented on Aug 21, 2024

    @IuliiaHerets
    Author

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

  4. IuliiaHerets commented on Aug 21, 2024

    @IuliiaHerets
    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

  5. bernhardoj commented on Aug 21, 2024

    @bernhardoj
    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};
    
  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 23, 2024
  7. melvin-bot commented on Aug 23, 2024

    @melvin-bot
  8. 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[/+] on Aug 23, 2024
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 23, 2024
  10. melvin-bot commented on Aug 23, 2024

    @melvin-bot

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

  11. 9 remaining items

  12. melvin-bot commented on Aug 26, 2024

    @melvin-bot

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

  13. added
    ReviewingHas a PR in review
    and removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 26, 2024
  14. bernhardoj commented on Aug 26, 2024

    @bernhardoj
    Contributor

    PR is ready

    cc: @s77rt

  15. 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[/+] on Sep 10, 2024
  16. johncschuster commented on Sep 11, 2024

    @johncschuster
    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!

  17. s77rt commented on Sep 11, 2024

    @s77rt
    Member

    @johncschuster This already has a regression test.

  18. johncschuster commented on Sep 12, 2024

    @johncschuster
    Contributor

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

  19. bernhardoj commented on Sep 12, 2024

    @bernhardoj
    Contributor

    Requested in ND.

  20. JmillsExpensify commented on Sep 12, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @s77rt

  21. JmillsExpensify commented on Sep 13, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions