Skip to content

Commit ba1ee78

Browse files
authored
fix(ui5-button): determine icon-only ignoring comment nodes (#1679)
We used to set icon-only if there are no childNodes, but in this case there are child nodes, because the comments are child nodes. Some styles, that rely on having a text are applied and the button does not look right, the icon is not centred as the button is wider than it should.
1 parent a00225c commit ba1ee78

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/main/src/Button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class Button extends UI5Element {
284284
console.warn(`In order for the "submits" property to have effect, you should also: import "@ui5/webcomponents/dist/features/InputElementsFormSupport.js";`); // eslint-disable-line
285285
}
286286

287-
this.iconOnly = !this.childNodes.length;
287+
this.iconOnly = !this.textContent;
288288
this.hasIcon = !!this.icon;
289289
}
290290

packages/main/test/pages/Button.html

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
</head>
3030

3131
<body style="background-color: var(--sapBackgroundColor);">
32+
33+
<ui5-button icon="home"><!----><!----></ui5-button>
3234
<ui5-icon name="invalid_name"></ui5-icon>
3335
<ui5-button design="Emphasized" icon="invalid_name">Press</ui5-button>
3436

0 commit comments

Comments
 (0)