Skip to content

[WC-3633] fix(image-web): apply height in viewport units - #2533

Merged
uicontent merged 1 commit into
combobox/fix-lightboxfrom
image/fix-viewport-height
Nov 17, 2026
Merged

uicontent merged 1 commit into
combobox/fix-lightboxfrom
image/fix-viewport-height

Conversation

@gjulivan

@gjulivan gjulivan commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

Stacked on #2511. Merge #2511 first; this PR then retargets to main.

Fixes one of the two older bugs QA listed on WC-3633 that #2511 did not cause and that also happen on main: a height in viewport units (vh) is never applied to the image on the page.

Cause. constructStyleObject (utils/helpers.ts) builds height: 30vh correctly, but ContentImage and BackgroundImage in components/Image/ui.tsx then overwrite style.height with getStyle(height, heightUnit). getStyle only handled pixels and percentage and returned "" for viewport, which removes the height.

Fix.

  • getStyle returns <value>vh for viewport.
  • Unit tests for an image and a background image with a height in viewport units. Both fail without the fix.
  • Changelog entry under Unreleased.

Verified in a Mendix 11.12.5 app at 1440 × 900, Image widget with a 400 × 300 px image, Width auto, Height 30 viewport:

Before After
Inline style on the <img> none height: 30vh;
Size on the page 400×300 (natural) 360×270
Enlarged (On click = Enlarge) 400×300 400×300

Not in this PR: the other leftover, Escape in a pop-up closing both the lightbox and the pop-up. It did not reproduce on Mendix 11.12.5 with Image 1.6.1. The Mendix pop-up closes on Escape only when focus is inside it, and the lightbox moves focus to itself when it opens. More details from QA are needed (Mendix version, browser, how the lightbox was opened).

What should be covered while testing?

  1. Add an Image widget, set Height unit to Viewport and Height to 30, and run the app.
  2. The image is 30% of the window height. Resize the window: the height follows.
  3. Repeat with Render as background image enabled: the background container is 30% of the window height.
  4. Pixel and percentage heights, and Height auto with minimum or maximum height, behave as before.

🤖 Generated with Claude Code

ContentImage and BackgroundImage overwrote the height from
constructStyleObject with getStyle(), which only handled pixels and
percentage and returned "" for viewport, so a height in vh was dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gjulivan
gjulivan requested a review from a team as a code owner November 16, 2026 22:05
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

✅ Approved — no issues found


What was reviewed

File Change
packages/pluggableWidgets/image-web/src/components/Image/ui.tsx getStyle now returns <value>vh for the viewport unit. Before, it returned "", which removed the height.
packages/pluggableWidgets/image-web/src/components/__tests__/Image.spec.tsx Two new tests for a viewport height, one on the image and one on the background image.
packages/pluggableWidgets/image-web/CHANGELOG.md New user-facing entry under Unreleased.

Skipped (out of scope): none

CI: pending: Snyk checks (code, license, security) · triage passed. Unit tests and E2E have not reported on this PR yet.


Positives

  • The fix is a small, targeted change at the root cause, which is getStyle overwriting the correct vh value from constructStyleObject.
  • The tests cover both render paths, the <img> and the background container.
  • The changelog entry follows the repo voice and describes behavior only.

@uicontent
uicontent merged commit 26166b3 into combobox/fix-lightbox Nov 17, 2026
4 of 5 checks passed
@uicontent
uicontent deleted the image/fix-viewport-height branch November 17, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants