Angular7 and NgbModal: how to remove default auto focus

The focus is needed to be within modal for accessibility and keyboard navigation reasons. By default the focus is on the first focusable element within modal, which in your case is the close button. You can add ngbAutofocus attribute to the element where you want the focus to be.

Focus management demo.

<button type="button" ngbAutofocus class="btn btn-danger"
      (click)="modal.close('Ok click')">Ok</button>

You can read more on github

It's an ugly hack, but you can add a non visible element as the first element:

<input type="text" style="display:none" />
Eudz

template.html

<button type="button" aria-label="Close">Close</button>

styles.css

button[aria-label="Close"] {
  &:focus {
    outline: none;
  }
}