Skip to content
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

fix(ui5-button): determine icon-only ignoring comment nodes #1679

Merged
merged 2 commits into from
May 26, 2020

Conversation

ilhan007
Copy link
Member

If we use the "ui5-button" internally in other component's template like this:

<ui5-button icon="{{this.icon}}">{{this.text}}</ui5-button>

And, if any button happens not to have a text, we will get the following result in the DOM:

<ui5-button icon="home"><!----><!----></ui5-button>

Then, in Button.js 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:

Screenshot 2020-05-22 at 10 40 47 PM

Now the icon-only is set properly, checking against the textContent as it does not include comments and the same button looks like a standard one:
Screenshot 2020-05-22 at 10 41 04 PM

Other possible way is to filter the child nodes by nodeType:

this.iconOnly = !Array.from(this.childNodes)
                       .filter(node => node.nodeType !== Node.COMMENT_NODE).length;

@ilhan007 ilhan007 merged commit ba1ee78 into master May 26, 2020
@ilhan007 ilhan007 deleted the fix-btn-sizing branch May 26, 2020 06:50
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.

2 participants