-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(web-components): remove empty text nodes from avatar #33963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(web-components): remove empty text nodes from avatar #33963
Conversation
d302e67 to
fe6f9b4
Compare
📊 Bundle size report✅ No changes found |
|
Pull request demo site: URL |
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
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 |
fe6f9b4 to
c1be15b
Compare
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
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.
9ec0f88 to
e714367
Compare
| if (!this.innerText.trim()) { | ||
| this.defaultSlot.assignedNodes().forEach(node => { | ||
| if (node.nodeType === Node.TEXT_NODE) { | ||
| (node as Element).remove(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
c487441 to
8495182
Compare
| if (!this.innerText.trim()) { | ||
| this.defaultSlot.assignedNodes().forEach(node => { | ||
| if (node.nodeType === Node.TEXT_NODE) { | ||
| (node as Element).remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
| 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(); | ||
| }); |
There was a problem hiding this comment.
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
|
@radium-v, @chrisdholt, @eljefe223 what is needed to get this into an updated web components release? (rc 2?) |
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
slotchangeevents that removes purely empty text nodes from the default slot. This only happens if there is no slottedinnerTextin the component.