How to correctly align via HTML the Submit button and Cancel button so that when I press the "Tab" in the keyboard, it will go from "Submit" then to "Cancel"? This is the ChildModalComponent:
<div class="w-100">
<button type="button" (click)="remove()" class="btn btn-primary mr-3 float-left" >Remove</button>
<button type="button" class="btn btn-info float-right" (click)="closeModal()" >Cancel</button>
<button type="submit" ngbAutofocus class="btn btn-primary mr-3 float-right" >Submit/button>
</div>
With this current code, on initial opening of modal, the "Tab" is highlighted on the Submit first since it has the ngbAutofocus. But when I click on the "Tab", the expected behavior should be to go to Cancel but it goes to the added "Close" button on my modal.
I am using import { NgbModal } from '@ng-bootstrap/ng-bootstrap' for my modal,
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
openModal = () => {
const modalRef = this.modalService.open(ParentModalComponent, {size: "xl", backdrop: "static"});
}
This is the ParentModalComponent:
<div class="modal-header">
<h3 class="modal-title w-100 text-center">Modal Header Here</h3>
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<app-child-modal></app-child-modal>
I've tried using "[tabIndex]='value', but when I continuously press "Tab", the focus goes outside the modal and I have to implement Focus Trapping but this is a lot of work.