Chat - Magnifying glass displayed anywhere on the modal page for small images
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Launch the app and login
- Add a small size image as attachment and send the image to any chat
- Click on the image thumbnail, it should open modal with the image
- Verify you see a magnifying glass when hovering over the image
Expected Result:
Magnifying glass displayed only when hovering the image
Actual Result:
Magnifying glass displayed on all the places
Workaround:
Unknown
Platform:
Where is this issue occurring?
- Web
- Desktop App
Version Number: 1.1.15.1 Reproducible in staging?: Yes Reproducible in production?: Yes Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:
https://user-images.githubusercontent.com/43996225/142030540-b71a9486-6622-4844-b776-3850ec0e5e35.mp4
Expensify/Expensify Issue URL: Issue reported by: Applause Slack conversation:
Triggered auto assignment to @timszot (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Triggered auto assignment to @mallenexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
Triggered auto assignment to @deetergp (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Job posted https://www.upwork.com/jobs/~014d495c62816efa38
Proposal
We can calculate the pressable size by calculating the final size of the image. The final size of the image can be calculated using the size of the container (extracted with onLayout) and the original size of the image (this.state.imgHeight and this.state.imgWidth).
We will need to add the following functions to src/components/ImageView/index.js:
storeImageContainerSize(event) {
if (this.state.imageContainer) {
// just do it first time to avoid potentially falling in a loop of update image size -> layout changes size -> update image size -> etc.
return;
}
this.setState({
imageContainer: {
height: event.nativeEvent.layout.height,
width: event.nativeEvent.layout.width,
ratio: event.nativeEvent.layout.height / event.nativeEvent.layout.width,
}
});
}
shouldUseImageSize() {
// We can use the calculated image size if we have all required sizes (original image size + container size) and we are not zoomed in
if (!this.state.imageContainer || !this.state.imgHeight || !this.state.imgWidth || this.state.isZoomed) {
return false;
}
return true;
}
getFinalImageWidth() {
if (this.state.imageContainer.width >= this.state.imgWidth && this.state.imageContainer.height >= this.state.imgHeight) {
// Image fits completely
return this.state.imgWidth;
}
const imageAspect = this.state.imgWidth / this.state.imgHeight;
const imageContainterAspect = this.state.imageContainer.width / this.state.imageContainer.height;
if (imageAspect > imageContainterAspect) {
// Image is wider than container
return '100%';
}
// Image is taller than container
return this.state.imageContainer.height * imageAspect;
}
getFinalImageHeight() {
if (this.state.imageContainer.width >= this.state.imgWidth && this.state.imageContainer.height >= this.state.imgHeight) {
// Image fits completely
return this.state.imgHeight;
}
const imageAspect = this.state.imgWidth / this.state.imgHeight;
const imageContainterAspect = this.state.imageContainer.width / this.state.imageContainer.height;
if (imageAspect > imageContainterAspect) {
// Image is wider than container
return this.state.imageContainer.width / imageAspect;
}
// Image is taller than container
return '100%';
}
We will adjust the current Pressable height and width:
https://github.com/Expensify/App/blob/main/src/components/ImageView/index.js#L171-L177
like this:
<Pressable
style={[
this.shouldUseImageSize() ? {height: this.getFinalImageHeight()} : styles.h100,
this.shouldUseImageSize() ? {width: this.getFinalImageWidth()} : styles.w100,
getZoomCursorStyle(this.state.isZoomed, this.state.isDragging),
]}
And the store the layout container size from Image:
https://github.com/Expensify/App/blob/main/src/components/ImageView/index.js#L213-L217
like this:
<Image
onLayout={e => this.storeImageContainerSize(e)}
source={{uri: this.props.url}}
style={getZoomSizingStyle(this.state.isZoomed, this.state.imgWidth, this.state.imgHeight, this.state.zoomScale)}
resizeMode={this.state.isZoomed ? 'contain' : 'center'}
/>
1. Replication I also was able to reproduce this issue in my web, desktop environment. Here are my replication videos - web issue - desktop issue
2. Problems
Problem is that cursor: zoom-in style was set to the parent component, but the parent size is bigger than the image itself when the modal is open.
3. Solution
We need to set the style cursor: zoom-in to the image area.
- Because the current image is clickable and wrapped by
Pressablecomponent, we need to set this style to thePressablecomponent. - While processing this issue, we need to keep the placement of the small image in the center of the modal.
To resolve this issue, we might use the
marginstyle, but it will not resolve thehover areacorrectly. It means the zoom icon will be displayed on the margin area. So we need to useposition: absolute, left: XXpx, top: YYpxproperty. - While calculating the
topvalue, we need to know the modal height. It can be get byonLayoutevent of the parent view. - By doing this, we will show the image at the center of the modal dialog with its original size and
zoom-incursor will be displayed only on the image area.

This is my solution to resolve this issue.
@deetergp , can you please review @CamilaRivera and @railway17 's proposals above?
Thank you both for your proposals @CamilaRivera & @railway17's. After reviewing them both, I'm inclined to go with @railway17 proposal is it's appears to get the job done with fewer changes.
π£ @railway17 You have been assigned to this job by @deetergp! Please apply to this job in Upwork and let us know when we can expect a PR to be ready for review π§βπ» Keep in mind: Code of Conduct | Contributing π
Hired @railway17 / MingYun H. in Upwork for the job.
@mallenexpensify , @deetergp
Nice to meet you.
I have a coincidence issue with my pc.
Actually, I reinstalled my OS to Big Sur after submitting my proposal on Sunday (my old OS version was Catalina).
As you saw in my proposal, I was able to replicate and test on the desktop app.
- desktop issue.
But I can't start the desktop app (web is working) on my side.
So, I can't upload a working video screenshot in the pull request. (this function was tested in my old system when I submit the proposal).
My current system info like below
macOS Big Sur
version 11.5.2(20G95)
I tried with node 12.x, 14.x and 17.x by using nvm.
But not working in all of the cases.
Error is like below:

Even though it was tested before, I would like to keep the rule to write the pull request description with attachments. Do you know how to run the desktop app in this environment?
I created a pull request with 2 videos (web fix was taken from my pc but desktop-fix video was taken from another pc). I will check this issue while you review it or might be later. And will submit here why it would not work.
Hi @railway17 , this is likely a better question for @deetergp who will be the one reviewing the PR. Scott, can you take a look above plz
Hi, @deetergp , @mallenexpensify I resolved this error by upgrading the dev package versions to latest one in package.json like below:
...
"electron": "^16.0.1",
"electron-builder": "^22.14.5",
"electron-notarize": "^1.1.1",
"electron-reloader": "^1.2.1",
....
Hey @railway17. Here are the versions I'm running on my Big Sur machine:
β App git:(han-fix-magnifying-glass) β node --version
v14.17.4
β App git:(han-fix-magnifying-glass) β npm --version
6.14.14
β App git:(han-fix-magnifying-glass) β nvm --version
0.38.0
β App git:(han-fix-magnifying-glass) β
Generally, when I run into these kinds of runtime issues, I find that just deleting the node_modules folder and re-running npm i takes care of them. FWIW, I was able to run your branch on the desktop app without any problems.
Issue not reproducible during KI retests. (First week)
The solution for this issue has been :rocket: deployed to production :rocket: in version 1.1.17-7 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/6437
- https://github.com/Expensify/App/pull/6535
If no regressions arise, payment will be issued on 2021-12-13. :confetti_ball:
The solution for this issue has been :rocket: deployed to production :rocket: in version 1.1.18-3 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/6535
If no regressions arise, payment will be issued on 2021-12-15. :confetti_ball:
We are tracking are a regression from this issue's PR. https://github.com/Expensify/App/issues/6518. It must be fixed before this issue can be paid out.
Also, this is @railway17 's first issue/PR in our repo so I think further assignment should be restrained until the regression is fixed,
Just to reiterate and confirm what @parasharrajat said above, this issue should not be considered complete until https://github.com/Expensify/App/issues/6518 is resolved as well.