Skip to content

fix(ui5-illustrated-message): add v5 loader in tnt illustrations#13160

Open
dobrinyonkov wants to merge 3 commits intomainfrom
fix/wrong-illustration-loaded-2
Open

fix(ui5-illustrated-message): add v5 loader in tnt illustrations#13160
dobrinyonkov wants to merge 3 commits intomainfrom
fix/wrong-illustration-loaded-2

Conversation

@dobrinyonkov
Copy link
Contributor

@dobrinyonkov dobrinyonkov commented Feb 26, 2026

Fixes #8145

Problem

When importing a single TNT illustration directly (e.g., import "@ui5/webcomponents-fiori/dist/illustrations/tnt/NoApplications.js"), the IllustratedMessage displayed V4 instead of V5 when using Horizon themes.

Solution

Modified the illustration generation script to register V5/V5-HC loaders for V4 TNT illustrations that have corresponding V5 versions. The loaders use dynamic imports, so V5 SVGs load lazily only when a Horizon theme is active.

Key Points

  • Only affects TNT illustrations (fiori set has no V5)
  • Checks V5 availability at build time (some TNT illustrations like UnableToLoad have no V5)
  • Maintains tree-shaking - only the specific illustration's V5 loader is registered
  • No regression for AllIllustrations.js

Design Decisions

Why V4 is imported directly, but V5 is lazy-loaded?

The current approach loads V4 SVGs directly and registers V5 as a lazy loader:

// V4 imported directly (always loaded)
import dialogSvg from "./tnt-Dialog-NoApplications.js";

// V5 loader registered (lazy, loaded only if Horizon theme)
registerIllustrationLoader("tnt/V5/NoApplications", async () => {
  return (await import("../../illustrations-v5/tnt/NoApplications.js")).default;
});

Why not import V5 directly too?

  • Theme is determined at runtime, not build time
  • Imports execute before any theme detection code runs
  • Users can switch themes dynamically at runtime
  • Importing both upfront would load unnecessary assets

Why not make both V4 and V5 lazy?
This would require moving V4 assets to a dedicated illustrations-v4/ folder and restructuring the illustration files to only register loaders. However:

  • would not be compatible for users who import SVGs directly (import { dialogSvg } from "...tnt/NoApplications.js")

…stration imports

When importing a single TNT illustration directly (e.g.,
import "@ui5/webcomponents-fiori/dist/illustrations/tnt/NoApplications.js"),
the IllustratedMessage was displaying the wrong illustration (V4) instead
of the correct one (V5) when using Horizon themes.

Root cause: Single V4 TNT illustration imports only registered V4 data.
Horizon themes (sap_horizon, sap_horizon_dark, sap_horizon_hcb, sap_horizon_hcw)
expect V5 illustrations, but no V5 loader was registered when importing
a single illustration file.

Solution: Modified the illustration generation script to also register
V5 and V5/HC loaders for each V4 TNT illustration. The loaders use
dynamic imports, so the V5 SVGs are loaded lazily only when actually
needed (i.e., when a Horizon theme is active). This maintains tree-shaking
benefits while ensuring correct illustration display.

Fixes #8145
@dobrinyonkov dobrinyonkov force-pushed the fix/wrong-illustration-loaded-2 branch from 68f8113 to b6994f0 Compare February 26, 2026 12:39
…stration imports

When importing a single TNT illustration directly (e.g.,
import "@ui5/webcomponents-fiori/dist/illustrations/tnt/NoApplications.js"),
the IllustratedMessage was displaying the wrong illustration (V4) instead
of the correct one (V5) when using Horizon themes.

Root cause: Single V4 TNT illustration imports only registered V4 data.
Horizon themes (sap_horizon, sap_horizon_dark, sap_horizon_hcb, sap_horizon_hcw)
expect V5 illustrations, but no V5 loader was registered when importing
a single illustration file.

Solution: Modified the illustration generation script to register V5 and
V5/HC loaders for V4 TNT illustrations that have corresponding V5 versions.
The loaders use dynamic imports, so the V5 SVGs are loaded lazily only
when actually needed (i.e., when a Horizon theme is active). This maintains
tree-shaking benefits while ensuring correct illustration display.

Note: Not all TNT illustrations have V5 versions (e.g., UnableToLoad,
EmptyContentPane, User2), so we check for V5 availability at build time.

Fixes #8145
Copy link
Contributor

@plamenivanov91 plamenivanov91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to write cypress test and test for the SVG in the DOM in order to support this complex logic ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[IllustratedMessage]: Not displaying correct illustration

2 participants