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(button): do not apply a width if there is button text with an icon #18343

Merged
merged 3 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions core/src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,8 @@ export class Button implements ComponentInterface {
}
}

private get hasLabel() {
return this.el.textContent !== null && this.el.textContent.trim() !== '';
}

private get hasIcon() {
return !!this.el.querySelector('ion-icon');
}

private get hasIconOnly() {
return this.hasIcon && !this.hasLabel;
return !!this.el.querySelector('ion-icon[slot="icon-only"]');
}

private get rippleType() {
Expand Down
38 changes: 34 additions & 4 deletions core/src/components/toolbar/test/spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
</ion-buttons>
<ion-buttons slot="primary">
<ion-button>
<ion-icon name="star"></ion-icon>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
</ion-buttons>
<ion-buttons slot="secondary">
<ion-button>
<ion-icon name="call"></ion-icon>
<ion-icon slot="icon-only" name="call"></ion-icon>
</ion-button>
</ion-buttons>
<ion-buttons slot="start">
Expand All @@ -138,12 +138,12 @@
</ion-buttons>
<ion-buttons slot="primary">
<ion-button>
<ion-icon name="star"></ion-icon>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
</ion-buttons>
<ion-buttons slot="secondary">
<ion-button>
<ion-icon name="call"></ion-icon>
<ion-icon slot="icon-only" name="call"></ion-icon>
</ion-button>
</ion-buttons>
<ion-buttons slot="start">
Expand Down Expand Up @@ -242,6 +242,36 @@

</ion-content>

<ion-footer>
<ion-toolbar>
<ion-title>
Click to Add Text
</ion-title>
<ion-buttons slot="end">
<ion-button id="changeText" onClick="toggleText()">
<ion-icon slot="start" name="refresh"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-footer>

<script>
const button = document.getElementById('changeText');

function toggleText() {
const hasText = button.querySelector('#childText');

if (hasText) {
button.removeChild(hasText);
} else {
var text = document.createElement('span');
text.innerHTML = 'Toggle';
text.id = 'childText';
button.appendChild(text, button);
}
}
</script>

<style>
ion-toolbar {
margin-bottom: 10px;
Expand Down