[Image] | (UX) | Stop large portrait images from overflowing in zoom view#3439
[Image] | (UX) | Stop large portrait images from overflowing in zoom view#3439
Conversation
…m overflowing in zoom view After removing the explicit dimension calculations for the zoom view, large portrait images started overlfowing and causing the zoom modal to have a scroll bar. Bringing the calculations back here, while still implementing the `scale` feature that was added since the calculations were previously removed. See [non-broken prod code](3f091b7#diff-ba490e8bdb7ae21cbdb97bb6f2ceb1853dcb0aa5dd26b0aa27ebb9c3e595c22a) for reference. Issue: none Test plan: See regression stories in the checks below. Storybook: - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image` - `/?path=/story/widgets-image-widget-demo--image-with-scaled-sizes`
…rtrait images from overflowing in zoom view
🗄️ Schema Change: No Changes ✅ |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (ac4fbdc) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3439If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3439If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3439 |
🛠️ Item Splitting: No Changes ✅ |
|
Size Change: +144 B (+0.03%) Total Size: 495 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
catandthemachines
left a comment
There was a problem hiding this comment.
Overall it looks good. Have a few nits and ideas, but non blocking.
| alt: "Portrait image", | ||
| }, | ||
| play: async ({canvas, userEvent}) => { | ||
| // eslint-disable-next-line testing-library/prefer-screen-queries |
There was a problem hiding this comment.
Why are we ignoring this eslint error. Could you fix this implementation?
There was a problem hiding this comment.
I believe this is necessary because our repo requires all queries to be screen.getByXyz(), but the Storybook interaction tests don't use React Testing LIbrary's screen - they have their own canvas element.
There was a problem hiding this comment.
This is a false positive. The linter for Testing Library sees these usages and thinks they're incorrect uses of Testing Library-related APIs, but in reality, they're Storybook APIs that just look like it.
So, it's correct to suppress these. But, we should probably suppress it for all of our .stories.tsx files.
Adding this to our .eslintrc.js file should do the trick (note that we already have an override that includes .stories.tsx files, but we can’t add this suppression there because that override also includes .test.ts and .test.tsx files.
"overrides": [
// ...other overrides...
{
"files": ["**/*.stories.@(js|jsx|ts|tsx)"],
"rules": {
"testing-library/prefer-screen-queries": "off"
}
}
]
| ? Math.max(contentScale, 2) | ||
| : Math.max(contentScale, 1); | ||
|
|
||
| // The scale that SvgImage will actually multiply dimensions by. |
There was a problem hiding this comment.
Overall this logic looks good to me. One question I had is have tried asking Claude if it has some ideas for optimizing the scaling code and edge cases? We have a lot of scaling all over the image widget area and it's becoming harder to track. Not something you need to fix here but a though to consider. 🤔
There was a problem hiding this comment.
Yeah, I think that's something I can look into as a separate investigation. I agree that it's getting confusing.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/[email protected] ### Patch Changes - [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size - [#3439](#3439) [`468910ec63`](468910e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Stop large portrait images from overflowing in zoom view - [#3436](#3436) [`634e65efab`](634e65e) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Radio] Fix color of text in correct option choice to match specs (theme-based green) ## @khanacademy/[email protected] ### Patch Changes - [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size - Updated dependencies \[[`94ad54eb43`](94ad54e), [`468910ec63`](468910e), [`634e65efab`](634e65e)]: - @khanacademy/[email protected] Author: khan-actions-bot Reviewers: claude[bot], anakaren-rojas Required Reviewers: Approved By: anakaren-rojas Checks: ⏭️ 2 checks have been skipped, ✅ 6 checks were successful Pull Request URL: #3437
…view (#3439) ## Summary: After removing the explicit dimension calculations for the zoom view, large portrait images started overlfowing and causing the zoom modal to have a scroll bar. Bringing the calculations back here, while still implementing the `scale` feature that was added since the calculations were previously removed. See [non-broken prod code](3f091b7#diff-ba490e8bdb7ae21cbdb97bb6f2ceb1853dcb0aa5dd26b0aa27ebb9c3e595c22a) for reference. Issue: none ## Test plan: See regression stories in the checks below. Storybook: - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state` - `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image` - `/?path=/story/widgets-image-widget-demo--image-with-scaled-sizes` | Before | After | | --- | --- | | <img width="1159" height="1042" alt="Screenshot 2026-03-31 at 11 24 08 AM" src="https://github.com/user-attachments/assets/c5a34c50-f394-4cae-b27f-83fe7bfad6b3" /> | <img width="1159" height="1045" alt="Screenshot 2026-03-31 at 11 23 55 AM" src="https://github.com/user-attachments/assets/0a75d210-9c0b-4962-9089-ba6107f55bb6" /> | Author: nishasy Reviewers: claude[bot], catandthemachines, nishasy, mark-fitzgerald, ivyolamit Required Reviewers: Approved By: catandthemachines Checks: ✅ 10 checks were successful, ⏭️ 1 check has been skipped Pull Request URL: #3439
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/[email protected] ### Patch Changes - [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size - [#3439](#3439) [`468910ec63`](468910e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Stop large portrait images from overflowing in zoom view - [#3436](#3436) [`634e65efab`](634e65e) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Radio] Fix color of text in correct option choice to match specs (theme-based green) ## @khanacademy/[email protected] ### Patch Changes - [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size - Updated dependencies \[[`94ad54eb43`](94ad54e), [`468910ec63`](468910e), [`634e65efab`](634e65e)]: - @khanacademy/[email protected] Author: khan-actions-bot Reviewers: claude[bot], anakaren-rojas Required Reviewers: Approved By: anakaren-rojas Checks: ⏭️ 2 checks have been skipped, ✅ 6 checks were successful Pull Request URL: #3437
Summary:
After removing the explicit dimension calculations for the zoom view,
large portrait images started overlfowing and causing the zoom modal
to have a scroll bar.
Bringing the calculations back here, while still implementing the
scalefeature that was added since the calculations were previously removed.
See non-broken prod code for reference.
Issue: none
Test plan:
See regression stories in the checks below.
Storybook:
/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image/?path=/story/widgets-image-widget-demo--image-with-scaled-sizes