Angular component launches Bootstrap modal in the background

I have a modal that opens from the table within the material tab

Below is the HTML code for the Modal:


    <div
        bsModal
        #createOrEditModal="bs-modal"
        class="modal fade"
        tabindex="-1"
        role="dialog"
        aria-labelledby="createOrEditModal"
        aria-hidden="true"
    >
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <form
                    *ngIf="active"
                    #landlordPropertyPortfolioForm="ngForm"
                    novalidate
                    (ngSubmit)="saveWithReason()"
                    autocomplete="off"
                >
                    <div class="modal-header">
                        <h4 class="modal-title">
                            <span *ngIf="landlordPropertyPortfolio.id">{{ l("EditLandlordPropertyPortfolio") }}</span>
                            <span *ngIf="!landlordPropertyPortfolio.id">{{ l("CreateNewLandlordPropertyPortfolio") }}</span>
                        </h4>
                        <button type="button" class="close" (click)="close()" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div *ngIf="!isNew" class="form-group">
                            <label for="LandlordPropertyPortfolio_Name">{{ l("Id") }}</label>
                            <input
                                type="text"
                                id="LandlordPropertyPortfolio_Id"
                                class="form-control"
                                [(ngModel)]="landlordPropertyPortfolio.id"
                                name="Id"
                                readonly
                            />
                        </div>
                        <div class="form-group">
                            <label for="LandlordPropertyPortfolio_Name">{{ l("Name") }}</label>
                            <input
                                type="text"
                                id="LandlordPropertyPortfolio_Name"
                                class="form-control"
                                [(ngModel)]="landlordPropertyPortfolio.name"
                                name="Name"
                                maxlength="0"
                                minlength="255"
                                required
                            />
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button [disabled]="saving" type="button" class="btn btn-default" (click)="close()">
                            {{ l("Cancel") }}
                        </button>
                        <button
                            type="submit"
                            class="btn btn-primary blue"
                            [disabled]="!landlordPropertyPortfolioForm.form.valid"
                            [buttonBusy]="saving"
                            [busyText]="l('SavingWithThreeDot')"
                        >
                            <i class="fa fa-save"></i> <span>{{ l("Save") }}</span>
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <change-reason-modal
        #changeReasonModal
        [dtoModel]="landlordPropertyPortfolio"
        (save)="save()"
        (close)="onChangeReasonModalClose()"
    >
    </change-reason-modal>

The modal opens from a component where there are tabs present.

Here is the code of a generic component with tabs:


    <div *ngIf="tabTemplates" class="row-fluid align-items-center margin-top-20 w-100">
        <mat-tab-group style="width: 100%;">
            <mat-tab *ngFor="let tabTemplate of tabTemplates" label="{{ tabTemplate.title }}">
                <ng-container *ngTemplateOutlet="tabTemplate.template"></ng-container>
            </mat-tab>
        </mat-tab-group>
    </div>

I am currently using Angular Material tabs, whereas previously I used tabset (as seen in the commented-out code). Now, I am facing an issue with the modal background not being clickable. How can I resolve this?

https://i.sstatic.net/o62Ea.png

Answer №1

If you haven't found the solution yet, I can help. I encountered the same issue and realized that it's not related to the z-index of the modal.

The problem lies in the fact that the z-index of mat-tab-body-active is set to 1, causing the content of the tab body to be hidden under the modal backdrop with a z-index of 1040.

To fix this, I added the following CSS to my component containing the mat-tab component to override the z-index of mat-tab-body-active when the modal is open:

::ng-deep .my-component-wrapper.modalOpened {
    .mat-tab-body-active {
        z-index: auto !important;
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ensuring Typescript Specifies a General Type While Retaining Specific Keys and Values

There are times when using as const at the end of an object declaration can be incredibly helpful, as it creates a literal singleton type. However, the drawback is that you lose the ability to specify a type without sacrificing the specific keys as shown i ...

When I define a type in TypeScript, it displays "any" instead

Imagine a scenario where we have a basic abstract class that represents a piece in a board game such as chess or checkers. export abstract class Piece<Tags, Move, Position = Vector2> { public constructor(public position: Position, public tags = nul ...

Exploring the compatibility of Next.js with jest for utilizing third-party ESM npm packages

Caught between the proverbial rock and a hard place. My app was built using: t3-stack: v6.2.1 - T3 stack Next.js: v12.3.1 jest: v29.3.1 Followed Next.js documentation for setting up jest with Rust Compiler at https://nextjs.org/docs/testing#setting-up-j ...

The toISOString() method is deducting a day from the specified value

One date format in question is as follows: Tue Oct 20 2020 00:00:00 GMT+0100 (Central European Standard Time) After using the method myValue.toISOString();, the resulting date is: 2020-10-19T23:00:00.000Z This output shows a subtraction of one day from ...

Sending data to a React component from regular HTML

I have a question about implementing a method to pass custom attributes from HTML elements as props to React components. Here's an example: function someFunction(props) { return <h1>props.something</h1> } HTML: <div id="someEl ...

Determine if an object in TypeScript generics includes a specific value

I have been working on a method to verify if a value retrieved from the database matches an enum. At first, I aimed to create a generic TypeGuard, but then I thought it would be beneficial to have a function that not only checks the value against the enum ...

Is it possible to set up an automatic redirection to the Identity Provider sign-in page when accessing a protected page in Next.js using Auth.js?

Currently in the process of developing a web platform utilizing [email protected] and Auth.js([email protected]). The provider has been configured with the given code, allowing successful signing in using the "Sign in" button. auth.ts import Ne ...

Ways to show a div when a dropdown option is selected

Currently, I am in the process of designing a form that includes a dropdown menu. Once the user selects a particular option from the list, such as: Software developer a new section will be displayed, showing two additional options: App Developer ...

[deactivated]: Modify a property's value using a different component

One of the requirements for my button is that it should be disabled whenever the callToActionBtn property is true. match-component.html <button [disabled]="callToActionBtn" (click)="sendTask()>Send</button> match-component.ts public callToA ...

Showing the state on a different page: A step-by-step guide

I'm currently in the process of creating a model for a real estate website. On the homepage, users can choose between 'rent' or 'purchase' using a select option and view the results on that page. I have successfully stored the sear ...

Having trouble accessing the 'value' property of undefined in Angular CLI

As a beginner in Angular, Angular CLI, Foundation, and Jquery, I am still learning and experiencing some challenges. Although I can retrieve information from my database, apply filters to display contacts of the same category, and show contact details with ...

Why is the value not being assigned by the Angular component from the observable service getter?

I am currently working on developing a filter set, and I am facing an issue with the salesChannels array content in my view. The array only gets populated after clicking a button that triggers the test() function. Interestingly, the first time I log the ar ...

Utilizing TypeScript with Msal-React for Prop Type Validation

I'm currently implementing authentication in my app using msal-React. Within my app, I have a component that utilizes msalcontext and is wrapped by withMsal: function App(props: any) { return ( <> <AuthenticatedTemplate> ...

The conclusion from utilizing the TypeScript class factory mixin is that it does not yield a constructor function

While attempting to utilize mixin classes in TypeScript, I encountered an issue. The return value of the mixin application (Sizeable.mixin() in the following code) is reported as "not a constructor function". However, it is puzzling because the error outpu ...

Utilize the grouping functionality provided by the Lodash module

I successfully utilized the lodash module to group my data, demonstrated in the code snippet below: export class DtoTransactionCategory { categoryName: String; totalPrice: number; } Using groupBy function: import { groupBy} from 'lodash&apo ...

`Implementing a Reusable RadioButton Component in Angular2`

When trying to reuse my component on the same page, I encountered an issue with defining the value of Radio Buttons based on the specific component I'm working with. I have three shared-components that need to be distinguished. If I modify one compon ...

Tips on applying border to unique marker icon in Angular2 using agm-marker

https://i.sstatic.net/HH36B.png Hello everyone, I've been working on a project and need some assistance. My goal is to dynamically add custom marker icons to specific lat/lng coordinates, each with additional values such as a "color name" for border ...

Tips for disabling the download prompt in Chrome with the help of Protractor

Customize Chrome options for better performance: 'chromeOptions': { args: [ 'disable-extensions', 'safebrowsing-disable-extension-blacklist', 'safebrowsing-disable-download-protection', ...

Establish a function within an interface using the name obtained from a constant in Typescript

How can I define functions within an interface using constants as function names? I have a const array containing event names and I want to create an ServerToClientEvents interface for SocketIO. I can define a function like this and it will work: interfac ...

The attribute 'pixiOverlay' is not found in the property

Working on my Angular 8 project, I needed to display several markers on a map, so I chose to utilize Leaflet. Since there were potentially thousands of markers involved, I opted for Leaflet.PixiOverlay to ensure smooth performance. After installing and imp ...