[Image] | (UX) | Show image in explore modal even when size is undefined#3367
[Image] | (UX) | Show image in explore modal even when size is undefined#3367
Conversation
…mal without feature flag
…image in explore modal even when size is undefined
🗄️ Schema Change: No Changes ✅ |
|
Size Change: +14 B (0%) Total Size: 486 kB
ℹ️ View Unchanged
|
🛠️ Item Splitting: No Changes ✅ |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (82c5b8b) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3367If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3367If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3367 |
| // bgWidth / bgHeight = X / modalImageHeight | ||
| // => X = (bgWidth / bgHeight) * modalImageHeight | ||
| width = | ||
| (backgroundImage.width / backgroundImage.height) * modalImageHeight; |
There was a problem hiding this comment.
I considered removing this block entirely, since the sizing just works with undefined now. However, I opted to keep this block here since it will be useful for the work in my other branch on scaled graphie labels.
There was a problem hiding this comment.
This file has a lot of changes because of the boilerplate code that had to be updated to allow the image to actually load for testing.
| !backgroundImage.height || | ||
| !backgroundImage.width || | ||
| !backgroundImage.url | ||
| ) { |
| background-color: var(--wb-semanticColor-core-background-base-default); | ||
| /* Stop large images from overflowing out of the image area of the modal. */ | ||
| max-width: 100%; | ||
| max-height: var(--modal-panel-height); |
There was a problem hiding this comment.
Large images would overflow and cover the long description without this CSS.
There was a problem hiding this comment.
This CSS looks appropriate. However, I would prefer some changes to how the CSS variables are handled. I realize that this may be beyond the intent of this PR, but these changes will help to avoid potential conflicts.
- Namespace the CSS variables
- Instead of
--modal-panel-height, I recommend using--perseus-image-modal-panel-height - This will prevent naming conflicts with other parts of the application that have a modal panel height variable of the same name.
- Instead of
- Attach the CSS variables to
.modal-containerinstead of:root- Even if variables are namespaced, adding them to the
:rootelement overloads that element with variables that don't apply anywhere else other than the image widget. - If the variables are NOT namespaced, then this runs the risk of overriding the variable if it exists anywhere else in frontend, or of being overridden by a setting elsewhere in frontend.
- Even if variables are namespaced, adding them to the
Claude Code ReviewThis repository is configured for manual code reviews. Comment |
|
Tested it in my local server with a PR tag using the exercise that I first noticed this issue in:
|
| display: flex; | ||
| width: 100%; | ||
| justify-content: center; | ||
| } |
There was a problem hiding this comment.
@mark-fitzgerald Is it okay for .modal-container to be defined in two spots like this to separate out where the variables are defined?


Summary:
We have a number of images in our content that are saved without a size.
If the image has a long description, it makes the "explore image" button available.
If the "explore image" button is clicked and then image has no size, the modal
shows up as completely empty.
The image should show up in the modal even if there is no size. Updating that here.
Issue: https://khanacademy.atlassian.net/browse/LEMS-3990
Test plan:
pnpm jest packages/perseus/src/widgets/image/components/explore-image-modal.test.tsxStorybook
/?path=/story/widgets-image-visual-regression-tests-interactions--long-description-clicked-state-with-no-size/?path=/story/widgets-image-visual-regression-tests-interactions--long-description-clicked-state-with-no-size-large-image/?path=/story/widgets-image-widget-demo--large-image-with-no-size-saved/?path=/story/widgets-image-widget-demo--large-image-with-no-size-saved-scale-flag