shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 242 forks source link

'x' close button does not render in the correct place in bootstrap plugin #405

Open rmcsharry opened 6 years ago

rmcsharry commented 6 years ago

Plunker: http://plnkr.co/edit/QtOzvr?p=preview

confirm modal

@Component({
  selector: 'modal-title',
  encapsulation: ViewEncapsulation.None,
  template: `<div [ngClass]="context.headerClass" [ngSwitch]="titleHtml">
      <button *ngIf="context.showClose" type="button" class="close" 
              aria-label="Close" (click)="dialog.dismiss()">
          <span aria-hidden="true">×</span>
      </button>
      <div *ngSwitchCase="1" [innerHtml]="context.titleHtml"></div>
      <h3 *ngSwitchDefault class="modal-title">{{context.title}}</h3>
 </div>`
})
export class BSMessageModalTitle {

I believe it should be like this:

@Component({
  selector: 'modal-title',
  encapsulation: ViewEncapsulation.None,
  template: `<div [ngClass]="context.headerClass" [ngSwitch]="titleHtml">
      <div *ngSwitchCase="1" [innerHtml]="context.titleHtml"></div>
      <h3 *ngSwitchDefault class="modal-title">{{context.title}}</h3>
      <button *ngIf="context.showClose" type="button" class="close" 
              aria-label="Close" (click)="dialog.dismiss()">
          <span aria-hidden="true">×</span>
      </button>
 </div>`
})
export class BSMessageModalTitle {
rmcsharry commented 6 years ago

If you modify the demo plunker by shortening the title you can see the problem clearly:

image

ashfaqch commented 6 years ago

Hope this example helps: https://github.com/ashfaqch/angular-modal-dialog-example

rmcsharry commented 6 years ago

@ashfaqch Thanks for the example but you have solved the problem by implementing your own template, and are not using the template in the library itself.

However your template does confirm that my suggested fix is correct:

...which is that the close button should be in the template BEFORE the modal title.

hahaliu005 commented 6 years ago

This problem still exists in ^6.0.0 version

bisigc commented 6 years ago

As a workaround I set the following css properties in my own style.css. This places the close button in the upper right corner of the modal header and the title is placed on the left side.

.modal-header .close {
    position: absolute;
    right: 0;
    margin: -1rem 0rem -1rem auto;
}
mohamednaleem commented 6 years ago

@bisigc It is working as expected after applying the class.