toggleable p-panel with button in header does not show correctly
I'm submitting a ... (check one with "x")
[X ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
https://embed.plnkr.co/M8pqevSJMieTf6xKZKeK/
Current behavior
When adding a button, that has a float:right, in the header of p-panel , that is toggleable, then the button is placed 'after' the toggleable icon. See Plukr
Expected behavior
the button is shown 'first', followed by the toggleable button of the panel
Minimal reproduction of the problem with instructions see https://embed.plnkr.co/M8pqevSJMieTf6xKZKeK/
What is the motivation / use case for changing the behavior? the toggleable button cannot be activated other than using [toggleable]="true". the button is in the p-header section. I presume that the toggleable button is 'appended' the p-header.
Please tell us about your environment: Not related to environment
-
Angular version: 5.X 5.1.3
-
PrimeNG version: 5.X
5.0.2 locally (5.2.0-rc.2 in Plunk)
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
-
Language: [all | TypeScript X.X | ES6/7 | ES5] see plunk
-
Node (for AoT issues):
node --version=
N/A
Can reproduce this on
-
PrimeNG 6.0.0-beta.1
-
Angular 6.0.0
-
FontAwesome 4.7.0
-
Browser Firefox 60.0.1, Google Chrome 67.0.3396.62, Mobile Chrome (unknown version)
Solution is rather simple:
-
npm install primeicons
-
in angular.json add in styles section: "node_modules/primeicons/primeicons.css",
The only question remaining is why primeng does not have primeicons as dependency? It would also be nice to have the docs updated to mention this!
=> ignore this => see above!
Workaround until fixed with: <p-panel [toggleable]="true" expandIcon="fa fa-plus" collapseIcon="fa fa-minus" >
Problems origin: https://github.com/primefaces/primeng/blame/1e93fdab163d46a6a4c1c90d28ae5c63f2f13d3b/src/app/components/panel/panel.ts#L60
this continues to exist:
https://github.com/primefaces/primeng/blame/master/src/app/components/panel/panel.ts#L60
https://github.com/primefaces/primeng/blame/d4de6cd57fa6f3ea059abeda734652afc53c2b3b/src/app/components/panel/panel.ts#L60
should be "fa fa-plus" and "fa fa-minus"
or pi-plus and pi-minus should be added in PrimeFont
This is expected since toggle icon also has float left, using CSS like flex you can the positions of anything in the header.
I came up with a solution that might be included in PrimeNG itself:
this is my scss override I used to make it work:
body {
.ui-panel {
.ui-panel-titlebar {
border-bottom: 1px solid $primaryDarkColor;
.ui-panel-title {
width: calc(100% - 30px);
display: inline-block;
.ui-panel-title-buttons {
float: right;
margin: -0.5em 0.3em;
}
}
.ui-panel-titlebar-icon {
margin-top: -0.15em;
margin-bottom: -0.15em;
}
}
}
}
and then the panel looks like this:
<p-panel [toggleable]="true">
<p-header>
<div class="ui-panel-title">
Custom header - button right
<div class="ui-panel-title-buttons">
<button pButton type="button" icon="ui-icon-close" title="Reply" class="remove-btn flat"></button>
<button type="button" label="Send" icon="ui-icon-send" pButton class="flat"></button>
<button pButton type="button" icon="ui-icon-close" title="Close" label="Close"
class="remove-btn orange-btn flat" style="margin-right:4px;"></button>
<button pButton type="button" icon="ui-icon-add" title="New" label="New"
class="message-btn secondary-btn flat"></button>
</div>
</div>
</p-header>
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's
business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like
the head of the family,
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the
good of the family.
</p-panel>
This solves 2 issues:
- the buttons are place to the left of the toggle button
- the height of the panel header with buttons is the same height as a normal panel (in the primeng samples this issue is also present
Please note that using
<p-panel header="my header">my content</p-panel>
still works the same and both approaches result in the same look and feel
@cagataycivici can you reopen the issue and include it in PrimeNG?