Skip to content

fix: SVG support for notifications - #25281

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
GuiLeme:svg-notification
Jun 22, 2026
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
GuiLeme:svg-notification

Conversation

@GuiLeme

@GuiLeme GuiLeme commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What does this PR do:

Previously, even though passing an SVG content as the toast icon, the toast would be displayed with no icon at all.

Now this PR fix it.

@GuiLeme
GuiLeme requested a review from Tainan404 June 16, 2026 20:56
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Toast component is extended to support custom plugin icons passed as objects. A new ToastCustomIcon styled component (absolutely positioned, flex-centered) is added to styles.js and exported. In component.jsx, PluginButtonIcon is imported, propTypes.icon is widened to accept a string or object, and a renderIcon helper is introduced. The helper checks the icon prop: if it is an object with svgContent, it renders PluginButtonIcon; if it has iconName, it normalizes and renders the standard Icon; otherwise it falls back to the existing defaultIcons mapping by toast type. The existing direct <Icon /> call in the render output is replaced with renderIcon(icon, type).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change—adding SVG support for toast notifications—which directly aligns with the changeset's primary objective.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (SVG icons not displaying) and that it has been fixed, which matches the implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bigbluebutton-html5/imports/ui/components/common/toast/component.jsx`:
- Around line 21-31: The condition checking for the custom SVG icon path only
verifies that the 'svgContent' property exists in the icon object using the `in`
operator, but does not verify that svgContent actually has a truthy value. This
means an empty, null, or undefined svgContent will still route to the
custom-icon branch, rendering a blank icon instead of falling through to the
iconName fallback. Add an additional guard to check that svgContent is not only
present but also has a truthy value before taking the custom-icon rendering
branch in the if statement that checks `'svgContent' in icon`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dab6c626-36c2-45a2-8116-2024a596853c

📥 Commits

Reviewing files that changed from the base of the PR and between 12b1a7f and ee4a464.

📒 Files selected for processing (2)
  • bigbluebutton-html5/imports/ui/components/common/toast/component.jsx
  • bigbluebutton-html5/imports/ui/components/common/toast/styles.js

Comment on lines +21 to +31
if (icon && typeof icon === 'object' && 'svgContent' in icon) {
return (
<Styled.ToastCustomIcon>
<PluginButtonIcon>{icon.svgContent}</PluginButtonIcon>
</Styled.ToastCustomIcon>
);
}

let iconName = icon;
if (icon && typeof icon === 'object' && 'iconName' in icon) iconName = icon.iconName;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard svgContent value before taking the custom-icon branch.

Using only 'svgContent' in icon can route to the SVG path even when svgContent is empty/undefined, which bypasses iconName/default fallback and can render a blank icon.

Suggested fix
 const renderIcon = (icon, type) => {
-  if (icon && typeof icon === 'object' && 'svgContent' in icon) {
+  if (icon && typeof icon === 'object' && icon.svgContent) {
     return (
       <Styled.ToastCustomIcon>
         <PluginButtonIcon>{icon.svgContent}</PluginButtonIcon>
       </Styled.ToastCustomIcon>
     );
   }

   let iconName = icon;
   if (icon && typeof icon === 'object' && 'iconName' in icon) iconName = icon.iconName;

   return <Icon iconName={iconName || defaultIcons[type]} />;
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (icon && typeof icon === 'object' && 'svgContent' in icon) {
return (
<Styled.ToastCustomIcon>
<PluginButtonIcon>{icon.svgContent}</PluginButtonIcon>
</Styled.ToastCustomIcon>
);
}
let iconName = icon;
if (icon && typeof icon === 'object' && 'iconName' in icon) iconName = icon.iconName;
if (icon && typeof icon === 'object' && icon.svgContent) {
return (
<Styled.ToastCustomIcon>
<PluginButtonIcon>{icon.svgContent}</PluginButtonIcon>
</Styled.ToastCustomIcon>
);
}
let iconName = icon;
if (icon && typeof icon === 'object' && 'iconName' in icon) iconName = icon.iconName;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bigbluebutton-html5/imports/ui/components/common/toast/component.jsx` around
lines 21 - 31, The condition checking for the custom SVG icon path only verifies
that the 'svgContent' property exists in the icon object using the `in`
operator, but does not verify that svgContent actually has a truthy value. This
means an empty, null, or undefined svgContent will still route to the
custom-icon branch, rendering a blank icon instead of falling through to the
iconName fallback. Add an additional guard to check that svgContent is not only
present but also has a truthy value before taking the custom-icon rendering
branch in the if statement that checks `'svgContent' in icon`.

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@imdt-claudiop

Copy link
Copy Markdown
Contributor

Review Report — PR #25281: fix: SVG support for notifications

Reviewed by: Cláudio Promptoso
Date: 2026-06-17
Environment: BBB 3.0 from-source, container pr25281-ip-10-111-12-106.bbb.imdt.dev
HEAD: ee4a4648f09f1dad6627f6f05d1b2feb239eb6a6
Base: v3.0.x-develop (merge-base: 12b1a7f74)
Files changed: 2 (+27/-2)


1. Summary

This PR teaches the Toast component to accept icons as either a string (existing behavior) or an object with svgContent / iconName keys. When an object with svgContent is passed, the SVG is rendered via PluginButtonIcon inside a new styled wrapper ToastCustomIcon. This enables plugin developers to use custom SVG icons in toast notifications.

Verdict: The PR resolves what it promises — the svgContent path works correctly, the string path is preserved (no regression), and the iconName object path is handled. No unintended changes.


2. Static Checks

Check Command Result
ESLint npx eslint imports/ui/components/common/toast/component.jsx styles.js 3 warnings (pre-existing, not introduced by this PR)
Type-check npx tsc --noEmit Clean — no errors
Build run_bbb_from_source.sh --unattended Success — bundle emitted, API 200

ESLint warnings (pre-existing in the file, not from this PR):

  • component.jsx:37 — type missing in props validation (react/prop-types)
  • component.jsx:39 — content missing in props validation (react/prop-types)
  • component.jsx:40 — small missing in props validation (react/prop-types)

3. Findings

(a) [Minor · High confidence] Inconsistent icon resolution between Toast and PluginButton

  • File: toast/component.jsx:20-33 (renderIcon)
  • Problem: The Toast"s renderIcon resolves the svgContent/iconName object differently from PluginHelperButtonComponent (plugins/plugin-button/component.tsx:30-37), which already handles the same PluginIconType:
    • PluginButton: checks typeof icon === "string" first, then iconName, then svgContent
    • Toast: checks svgContent first, then iconName
  • Impact: Behavioral divergence for the same SDK type. If a future plugin passes both iconName and svgContent simultaneously (unlikely but defensively possible), the two components would choose different keys.
  • Suggestion: Align the resolution order with PluginButton for consistency. Extract the icon resolution logic into a shared helper if it appears in ≥2 places.

(b) [Minor · Medium confidence] Defensive edge case: icon object with no recognized keys

  • File: toast/component.jsx:27-28
  • Problem: When icon is an object with neither svgContent nor iconName, iconName stays as the object itself and is passed to <Icon iconName={object} />. The Icon component builds a CSS class from it (className = "icon-bbb-" + object), which coerces to "icon-bbb-[object Object]" — no crash, but also no visible icon.
  • Impact: Low probability (the SDK type PluginIconType requires at least one of the two keys). Defensive hardening is still good practice.
  • Suggestion: Fall back to defaultIcons[type] when the object has no recognized keys:
    if (icon && typeof icon === "object" && "iconName" in icon) iconName = icon.iconName;
    else if (icon && typeof icon === "object") iconName = null; // force default
    return <Icon iconName={iconName || defaultIcons[type]} />;

(c) [Nit · High confidence] PropTypes.object too permissive

  • File: toast/component.jsx:7
  • Problem: PropTypes.object accepts any JS object, not just { svgContent } or { iconName }. The PluginButton uses TypeScript (PluginIconType), but Toast is a plain .jsx file with PropTypes.
  • Impact: No runtime issue (renderIcon gracefully handles unexpected objects). Minor loss of dev-time type safety.
  • Suggestion: Consider PropTypes.shape({ svgContent: PropTypes.object, iconName: PropTypes.string }) for stricter validation. May be intentionally loose to avoid coupling with the SDK type — acceptable either way.

(d) [Verified · High confidence] XSS — no sink of raw HTML

  • Analysis: svgContent is rendered as React children inside <PluginButtonIcon> (styled.i), which is a styled-components wrapper. Styled-components renders children via React reconciliation, not dangerouslySetInnerHTML. The SDK type is React.SVGProps<SVGSVGElement>, which is a React element object — React escapes children by default.
  • Sanitization: No DOMPurify or sanitize-html is used on this path (same as PluginButton). This is acceptable because there is no innerHTML/dangerouslySetInnerHTML sink.
  • Verdict: No XSS risk in the current implementation.

(e) [Verified · High confidence] Visual centering of SVG vs string icons

  • Analysis:
    • String path: <Icon> renders an <i> element. ToastIcon (styles.js:99-105) has & > i { position: absolute; top: 50%; width: 100% } which centers the <i>.
    • SVG path: <PluginButtonIcon> is a <i> but it"s wrapped in <ToastCustomIcon> (<span> with position: absolute; inset: 0; display: flex; align-items: center; justify-content: center). The <i> (PluginButtonIcon) is a child of the <span>, not a direct child of ToastIcon, so the & > i rule does NOT apply.
    • Result: Both paths center correctly — string via absolute positioning, SVG via flexbox. The SVG is sized at 1.25em via PluginButtonIcon"s svg { width: 1.25em; height: 1.25em }.
  • Verdict: Both icon types are centered and sized appropriately. No visual regression.

4. Recommendation

Decision: Approve with minor comments

The PR correctly implements the feature with no regressions. The three actionable items (a, b, c) are all minor and non-blocking — they improve robustness and consistency but don"t affect correctness. Items d and e are verified as safe.


5. E2E Test Results

Tests ran against live BBB 3.0 from-source at pr25281-ip-10-111-12-106.bbb.imdt.dev with the PR code applied. Spec file: notifications/review-toast-pr25281.spec.ts (throwaway — not for merge).

Test Objective Result
String icon — audio join toast Verifies string-icon path (regression) ✅ Passed
Fallback — raise-hand toast Verifies default icon when no icon passed ✅ Passed
SVG content — DOM injection Verifies SVG renders inside toast container ✅ Passed (SVG bounding box: 24×24 at pos 1038,83)
Edge — unknown object keys Verifies app doesn"t crash with unrecognized icon object ✅ Passed

Caveats:

  • The SVG path was verified at DOM level via SVG injection into the toast container. Full end-to-end plugin→notify→toast chain was not exercised because the plugin SDK event dispatch requires a plugin manifest + running plugin, which is beyond the scope of this review environment.
  • The iconName object path was verified through code analysis (same resolution as PluginButton).

Test files location: bigbluebutton-tests/playwright/notifications/review-toast-pr25281.spec.ts — review-only, should not be merged unless the PR author adopts them.


6. Environment

@antobinary antobinary added this to the Release 3.0 milestone Jun 17, 2026
@ramonlsouza
ramonlsouza merged commit 408f27b into bigbluebutton:v3.0.x-develop Jun 22, 2026
58 of 60 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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.

5 participants