[Image] | (UX) | Align caption to image in case where image has no size#3411
[Image] | (UX) | Align caption to image in case where image has no size#3411
Conversation
… case where image has no size There's a bug where the caption is not aligned to the image if the image has no size, and it stretches as far as possible instead. Trying to fix that here. Issue: https://khanacademy.atlassian.net/browse/LEMS-3966 Test plan: Storybook - `/?path=/story/widgets-image-visual-regression-tests--image-without-width-or-height-with-caption-title-and-long-description` - `/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved` - `/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved-scale-flag`
…ption to image in case where image has no size
🗄️ Schema Change: No Changes ✅ |
|
Size Change: -3 B (0%) Total Size: 494 kB
ℹ️ View Unchanged
|
🛠️ Item Splitting: No Changes ✅ |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (4f57e97) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3411If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3411If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3411 |
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.
Tip: disable this comment in your organization's Code Review settings.
| // `backgroundImage` - this is the width intended to be used when rendering | ||
| // the image within the content item. | ||
| const maxWidth = | ||
| backgroundImage.width && backgroundImage.height |
There was a problem hiding this comment.
Nit: Does a check of backgroundImage.height need to be performed here if we are just using backgroundImage.width?
There was a problem hiding this comment.
I would prefer to go the undefined route in the case that the width exists but the height doesn't (although it is very unlikely to happen), as the height would be treated as 0 in that case and the image would not be visible.
There was a problem hiding this comment.
Never mind. That happens whether I add the && backgroundImage.height or not.
| style={{ | ||
| maxWidth: scaleFF ? backgroundImage.width : zoomWidth, | ||
| }} | ||
| style={{flex: 1, minWidth: 0}} |
There was a problem hiding this comment.
A comment about why each style property is being set would be helpful.
mark-fitzgerald
left a comment
There was a problem hiding this comment.
CSS changes look good.
catandthemachines
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks Nisha!
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
…ze (#3411) ## Summary: There's a bug where the caption is not aligned to the image if the image has no size, and it stretches as far as possible instead. Trying to fix that here. Issue: https://khanacademy.atlassian.net/browse/LEMS-3966 ## Test plan: Storybook - `/?path=/story/widgets-image-visual-regression-tests--image-without-width-or-height-with-caption-title-and-long-description` - `/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved` - `/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved-scale-flag` ### Before: <img width="1439" height="530" alt="Screenshot 2026-03-26 at 1 24 58 PM" src="https://github.com/user-attachments/assets/ac9cecd0-2ca9-4cc6-adc2-4780240c8b8d" /> ### After: <img width="1440" height="533" alt="Screenshot 2026-03-26 at 1 25 24 PM" src="https://github.com/user-attachments/assets/81b11f62-93a5-4692-a3f9-58e330a845ec" /> Author: nishasy Reviewers: claude[bot], mark-fitzgerald, catandthemachines, nishasy, ivyolamit Required Reviewers: Approved By: mark-fitzgerald, catandthemachines Checks: ⏭️ 1 check has been skipped, ✅ 10 checks were successful Pull Request URL: #3411
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:
There's a bug where the caption is not aligned to the image if the image has no size,
and it stretches as far as possible instead.
Trying to fix that here.
Issue: https://khanacademy.atlassian.net/browse/LEMS-3966
Test plan:
Storybook
/?path=/story/widgets-image-visual-regression-tests--image-without-width-or-height-with-caption-title-and-long-description/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved/?path=/story/widgets-image-widget-demo--small-image-with-no-size-saved-scale-flagBefore:
After: