Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.03k stars 2.54k forks source link

Fix pdf blinks when open it #42333

Closed bernhardoj closed 1 week ago

bernhardoj commented 2 weeks ago

Details

The blink happens because we change the component tree when the pdf loads completes which will recreate the pdf component again. This PR fix it.

Fixed Issues

$ https://github.com/Expensify/App/issues/42103 PROPOSAL: https://github.com/Expensify/App/issues/42103#issuecomment-2110325553

Tests

Same as QA Steps

Offline tests

Same as QA Steps

QA Steps

Prerequisite: send a pdf attachment

  1. Open the chat with the pdf attachment
  2. Press the pdf preview to open the attachment
  3. Verify the pdf doesn't blink
    • [x] Verify that no errors appear in the JS console

PR Author Checklist

Screenshots/Videos

Android: Native https://github.com/Expensify/App/assets/50919443/cd78b219-5bd9-4599-9be0-f5c1c5578991
Android: mWeb Chrome https://github.com/Expensify/App/assets/50919443/ffc5f609-2a47-45ce-aa7f-a99813fe9b1f
iOS: Native https://github.com/Expensify/App/assets/50919443/a5c56d1f-ab3e-4673-9a80-ffdcff5fa1e3
iOS: mWeb Safari https://github.com/Expensify/App/assets/50919443/3f683de7-5ca2-4638-8842-2e0e48200af4
MacOS: Chrome / Safari https://github.com/Expensify/App/assets/50919443/1903adfa-4970-440d-994f-0c73d3e5aac4
MacOS: Desktop https://github.com/Expensify/App/assets/50919443/6e9ae2b5-6f0a-48b8-b15a-6f41ff77d52a
melvin-bot[bot] commented 2 weeks ago

@mananjadhav Please 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]

bernhardoj commented 2 weeks ago

@mananjadhav I tested a multi-page PDF and I can't scroll it on Android, basically this PR will reraise https://github.com/Expensify/App/issues/20867 again. https://github.com/Expensify/App/issues/20867 is the one that causes our issue here. The root cause is explained on the proposal there, but in short, it's because our Pressable component when disabled doesn't really disable the Pressable, but just pass an undefined event handler to it.

https://github.com/Expensify/App/blob/e8ae3c5acedf0e6788dc574c7b6f3043ca37092a/src/components/Pressable/GenericPressable/BaseGenericPressable.tsx#L139-L143

I think to solve both issues, we should have a new prop for Pressable called something like, fullDisabled and use it to set the disabled props of BaseGenericPressable. What do you think?

mananjadhav commented 1 week ago

when disabled doesn't really disable the Pressable, but just pass an undefined event handler to it.

@bernhardoj I don't completely follow what you mean? You mean in our PR or the props in general? I am not sure if we really need fullDisabled. Can you rephrase what you mean? May be we can then come up with an alternative.

cc - @blimpich

bernhardoj commented 1 week ago

@mananjadhav that's how the disabled props of our custom Pressable currently works as shown in this code. https://github.com/Expensify/App/blob/e8ae3c5acedf0e6788dc574c7b6f3043ca37092a/src/components/Pressable/GenericPressable/BaseGenericPressable.tsx#L139-L143

There is no disabled={disabled}. We are just passing an undefined callback, so the pressable responder is still working. The only way to disable the responder is by setting the RN Pressable disabled to true.

mananjadhav commented 1 week ago

and what happens if we actually add disabled: true in here.

https://github.com/Expensify/App/blob/e8ae3c5acedf0e6788dc574c7b6f3043ca37092a/src/components/Pressable/GenericPressable/index.native.tsx#L9-L12

bernhardoj commented 1 week ago

It will still be the same since we take out the disabled props from the ...rest props.

https://github.com/Expensify/App/blob/e8ae3c5acedf0e6788dc574c7b6f3043ca37092a/src/components/Pressable/GenericPressable/BaseGenericPressable.tsx#L22-L38

mananjadhav commented 1 week ago

Okay I am okay having a fullDisabled prop. @blimpich Any thoughts?

blimpich commented 1 week ago

Fine by me 👍

mananjadhav commented 1 week ago

@bernhardoj Can we work on the fix?

bernhardoj commented 1 week ago

@mananjadhav updated

mananjadhav commented 1 week ago

Reviewer Checklist

Screenshots/Videos

Android: Native https://github.com/Expensify/App/assets/3069065/68ac5744-43af-4822-b4f7-f1274fa7cf12
Android: mWeb Chrome https://github.com/Expensify/App/assets/3069065/5a74f9a2-06ec-422c-88c9-484f06c44178
iOS: Native https://github.com/Expensify/App/assets/3069065/b8f54e3e-4a37-4bfb-903f-3fe053eb013c
iOS: mWeb Safari https://github.com/Expensify/App/assets/3069065/18aed80e-d182-425c-b0ad-68e1581d9499
MacOS: Chrome / Safari https://github.com/Expensify/App/assets/3069065/b0ed2e51-b35b-40ef-a54f-29ed8eb751ba
MacOS: Desktop https://github.com/Expensify/App/assets/3069065/35bf77bb-7610-461a-88b9-e38d7b9ec6b9
OSBotify commented 1 week ago

:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

OSBotify commented 5 days ago

🚀 Deployed to staging by https://github.com/chiragsalian in version: 1.4.76-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
OSBotify commented 3 days ago

🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.76-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅