Skip to content

fix(ui): port renderIcon → <Icon> component to 1.13 (backport #31982) - #32066

Merged
Rohit0301 merged 6 commits into
1.13from
fix/renderIcon-to-Icon-1.13
Aug 26, 2026
Merged

Rohit0301 merged 6 commits into
1.13from
fix/renderIcon-to-Icon-1.13

Conversation

@Rohit0301

@Rohit0301 Rohit0301 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backport of #31982 to the 1.13 branch.

  • Adds components/common/Icon/Icon.tsx — renders known icon names synchronously, shows a loading skeleton for image URLs and swaps to the real <img> or a caller-supplied fallback based on actual browser onLoad/onError outcome, instead of pre-validating only the URL shape with a regex.
  • Removes renderIcon from utils/IconUtils.tsx and migrates all 1.13 call sites to <Icon>.
  • Adapted for 1.13 differences: CertificationTag preserves showName ? 16 : 28 / showName ? 14 : 20 size variants; DataProductUtils / DomainUtils use 1.13 class names (data-product-default-icon, domain-default-icon, no tw:text-quaternary).
  • Also migrates MUIIconPicker.tsx (a 1.13-only call site not present in main).

Files changed (13):

  • components/common/Icon/Icon.tsx (new)
  • components/common/Icon/Icon.test.tsx (new)
  • utils/IconUtils.tsx — removed renderIcon
  • utils/IconUtils.test.tsx — removed renderIcon tests
  • components/Certification/Certification.component.tsx
  • components/Tag/TagsV1/TagsV1.component.tsx
  • components/common/CertificationTag/CertificationTag.tsx
  • components/common/CertificationTag/CertificationTag.test.tsx
  • components/common/IconPicker/MUIIconPicker.tsx
  • pages/TagPage/TagPage.tsx
  • utils/ClassificationUtils.tsx
  • utils/DataProductUtils.tsx
  • utils/DomainUtils.tsx

Fixes #29895

🤖 Generated with Claude Code

Greptile Summary

The PR replaces renderIcon with a shared stateful <Icon> component and migrates the existing icon consumers.

  • Restores the certification-card image size to 40px while retaining 28px named icons.
  • Moves IconProps into the repository-standard dedicated interface file.
  • Adds loading, browser load/error handling, fallback rendering, and associated tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx Adds the shared component for named icons and asynchronously loaded image icons with skeleton and fallback behavior.
openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.interface.ts Moves the component props into a dedicated interface file, resolving the previous organization concern.
openmetadata-ui/src/main/resources/ui/src/components/Certification/Certification.component.tsx Restores the prior 40px custom-image size while preserving the 28px named and fallback icon sizes.
openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.test.tsx Covers named icons, image lifecycle states, fallbacks, styling, and cached-image handling.

Reviews (6): Last reviewed commit: "fix(ui): remove padding from .certificat..." | Re-trigger Greptile

Adds the new Icon component (components/common/Icon/Icon.tsx) that renders
icon names synchronously and image URLs with a loading skeleton + real
onLoad/onError fallback, replacing the stateless renderIcon regex-only helper.

Migrates all 1.13 call sites:
- Certification.component, TagsV1, CertificationTag (preserves 1.13 size variants)
- TagPage, ClassificationUtils, DataProductUtils, DomainUtils
- MUIIconPicker (1.13-only call site not in main PR)

Removes renderIcon from IconUtils.tsx and its tests from IconUtils.test.tsx.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@Rohit0301
Rohit0301 requested a review from a team as a code owner August 25, 2026 17:06
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added the UI UI specific issues label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

When a new tag is added the table unmounts and remounts <Icon> components.
On remount loadState resets to 'loading' and the img is hidden. For already-
cached images the browser fires the DOM load event synchronously while
creating the <img> element — before React attaches its onLoad listener — so
the event is silently dropped and the image stays hidden forever.

Fix: add imgRef to the <img> and a second useEffect[loadState] that checks
img.complete immediately after every 'loading' transition. If the browser
already holds the image, complete is true right after mount and we resolve
the state without waiting for the missed event.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

The <span> wrapper had no width/height of its own, causing two issues:
- Layout shift between loading (Skeleton) and loaded (img) states because
  the span is display:inline and collapses to its child's size.
- className passed by callers (e.g. certification-img) landed on the <span>
  rather than the <img>, breaking CSS selectors like img.certification-img.

Fix:
- Set display:inline-flex + width/height:size + flexShrink:0 on the span so
  the layout box is stable regardless of which child is visible.
- Move className from <span> to <img> so element-type CSS selectors work.
- Remove the now-redundant flexShrink:0 from TagsV1's wrapperStyle (the
  span provides it by default).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

JSX elements are always truthy objects, so `renderedIcon ?` was always
true whenever iconURL was set — even when <Icon> produced no visible
output. For certifications whose iconURL is neither in ICON_MAP nor a
valid image URL, <Icon> returned an empty fragment but the truthy check
still wrapped it in <div className="certification-icon">, leaving an
empty div.

Fix: remove the isIcon / renderedIcon variables and the 3-way conditional
entirely. Replace with a direct <Icon fallback={<CertificationIcon/>}> call
always inside .certification-icon, so every case (named icon, image URL,
unknown value, no iconURL) is handled correctly by the component itself.
Also drop the now-unused isImageUrl import.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

- Move IconProps to Icon.interface.ts per repo convention (greptile
  comment: prop interfaces belong in dedicated .interface.ts files)
- Restore size=40 for image URLs in Certification.component.tsx —
  original 1.13 code used size=28 for named SVG icons and size=40 for
  image URLs; our migration collapsed both to 28 incorrectly

The gitar-bot className comment is already resolved: className lands on
<img> (not <span>) since the span-size fix commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Rohit0301 Rohit0301 self-assigned this Aug 25, 2026
@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Aug 25, 2026
@gitar-bot

gitar-bot Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Ports the renderIcon utility to a stateful Icon component with robust image loading and fallback handling, addressing findings related to image certification icon sizes and wrapper class names.

✅ 2 resolved
✅ Bug: Image certification icons shrink from 40px to 28px

📄 openmetadata-ui/src/main/resources/ui/src/components/Certification/Certification.component.tsx:161-164
In the old code the certification list rendered image-URL icons at size: isIcon ? 28 : 40, so image-based certification icons displayed at 40px while named icons used 28px. The migrated code hardcodes size={28} for <Icon>, so image-URL certification icons now render 30% smaller in the certification picker. The isIcon flag is still used only to choose the wrapper div, so the size distinction was dropped unintentionally. Restore the conditional size to preserve the prior visual behavior.

✅ Quality: caller className now lands on wrapper span, not the <img>

📄 openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx:75-89 📄 openmetadata-ui/src/main/resources/ui/src/pages/TagPage/TagPage.tsx:673-677
The old renderIcon applied the caller's className directly to the rendered <img>. In the new Icon component, for image-URL values the className is applied to the wrapping <span> while the <img> gets only inline styles (width/height/objectFit). Call sites that pass classes intended to style the image itself (e.g. certification-img, object-contain in TagPage) no longer affect the <img>. For the current call sites the effect is benign (dimensions happen to match the inline size and objectFit is hardcoded), but this is a subtle contract change—consider forwarding className to the <img> (using wrapperStyle/imageStyle for the span) to avoid future surprises.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

❌ UI Checkstyle Failed

❌ ESLint + Prettier + Organise Imports (src)

One or more source files have linting or formatting issues.

❌ Core Components - I18n Sync

Core-components t() keys, locale files, or language-set are out of sync. Run yarn check-i18n-all locally.

❌ Tailwind Audit

Hardcoded Tailwind values found. Use a design-system utility (run yarn tw-audit:report for the token each value maps to).

❌ Antd + Less Deprecation Guard

A new antd import or new .less file was added. Use UntitledUI + Tailwind for new work.

Affected files

at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
at node:internal/main/run_main_module:36:49 {


Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.52% (61225/96386) 44.92% (33651/74910) 46.78% (10254/21917)

@sonarqubecloud

Copy link
Copy Markdown

@Rohit0301
Rohit0301 merged commit 071233b into 1.13 Aug 26, 2026
129 of 142 checks passed
@Rohit0301
Rohit0301 deleted the fix/renderIcon-to-Icon-1.13 branch August 26, 2026 06:48

This branch was previously deployed

1 inactive deployment
test — 7656279f Deployed Aug 25, 2026 by Rohit0301 via playwright-ci-postgresql (2, 6) #73640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants