Skip to content

Conversation

@radium-v
Copy link
Contributor

Previous Behavior

The <fluent-avatar> web component displays as empty when blank content is present in the default slot. This causes the default fallback icon to disappear when there's no text content to display.

New Behavior

This PR adds a routine on slotchange events that removes purely empty text nodes from the default slot. This only happens if there is no slotted innerText in the component.

@radium-v radium-v requested a review from a team as a code owner March 10, 2025 20:51
@radium-v radium-v force-pushed the users/radium-v/wc-avatar-empty-slot branch from d302e67 to fe6f9b4 Compare March 10, 2025 20:53
@github-actions
Copy link

github-actions bot commented Mar 10, 2025

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

Pull request demo site: URL

@@ -0,0 +1,7 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual regressions to review in the fluentui-web-components-v3 Visual Regression Report

Accordion 1 screenshots
Image Name Diff(in Pixels) Image Type
Accordion. - Dark Mode.normal.chromium_1.png 2660 Changed
Avatar 4 screenshots
Image Name Diff(in Pixels) Image Type
Avatar.Active.normal.chromium.png 97 Changed
Avatar.Active Appearance.normal.chromium.png 142 Changed
Avatar. - Dark Mode.normal.chromium_1.png 136 Changed
Avatar.Size.normal.chromium.png 953 Changed
Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
Badge. - Dark Mode.normal.chromium.png 511 Changed
Checkbox 1 screenshots
Image Name Diff(in Pixels) Image Type
Checkbox. - Dark Mode.normal.chromium_1.png 3 Changed
RadioGroup 1 screenshots
Image Name Diff(in Pixels) Image Type
RadioGroup. - Dark Mode.normal.chromium_1.png 62 Changed
TextInput 1 screenshots
Image Name Diff(in Pixels) Image Type
TextInput. - Dark Mode.normal.chromium_1.png 288 Changed

@radium-v radium-v force-pushed the users/radium-v/wc-avatar-empty-slot branch from fe6f9b4 to c1be15b Compare April 15, 2025 02:35
@@ -0,0 +1,7 @@
{
Copy link

@github-actions github-actions bot Apr 15, 2025

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Avatar 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Avatar. - Dark Mode.normal.chromium_1.png 298 Changed
vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 443 Changed
vr-tests-web-components/MenuList 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - Dark Mode.normal.chromium.png 498 Changed
vr-tests-web-components/MenuList. - RTL.2nd selected.chromium_3.png 38816 Changed
vr-tests-web-components/MenuList. - RTL.1st selected.chromium_2.png 39384 Changed
vr-tests-web-components/MenuList. - RTL.normal.chromium_1.png 39083 Changed
vr-tests-web-components/RadioGroup 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/RadioGroup. - Dark Mode.normal.chromium_1.png 89 Changed

There were 2 duplicate changes discarded. Check the build logs for more information.

@radium-v radium-v force-pushed the users/radium-v/wc-avatar-empty-slot branch 2 times, most recently from 9ec0f88 to e714367 Compare April 15, 2025 02:49
if (!this.innerText.trim()) {
this.defaultSlot.assignedNodes().forEach(node => {
if (node.nodeType === Node.TEXT_NODE) {
(node as Element).remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does editing the slot inside the slotchange event cause the slotchange event to fire again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

if (!this.innerText.trim()) {
this.defaultSlot.assignedNodes().forEach(node => {
if (node.nodeType === Node.TEXT_NODE) {
(node as Element).remove();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Comment on lines +31 to +36
test('should render an icon when no name or initials are provided', async ({ fastPage }) => {
const { element } = fastPage;
const icon = element.locator('svg');

await expect(icon).toBeVisible();
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test doesn't handle the scenario where the slotted content is only blank content

@vnbaaij
Copy link
Contributor

vnbaaij commented Jan 9, 2026

@radium-v, @chrisdholt, @eljefe223 what is needed to get this into an updated web components release? (rc 2?)

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