Issue with Bootstrap 4.2 modal: Unable to edit input fields, button cannot be clicked, modal does not close

https://i.sstatic.net/vHnVG.png https://i.sstatic.net/MhU3f.png

Utilizing Bootstrap 4.2.1, I have a modal that opens via a specific link:

<a href="#" data-toggle="modal" data-target="#inviteByEmailPopup" data-backdrop="false" data-keyboard="false">Add by Email</a>

The modal div is placed at the end of the document, right before the closing body tag

<div class="modal fade" tabindex="-1" role="dialog" id="inviteByEmailPopup" aria-hidden="true">
    <div class="modal-dialog" role="document" data-backdrop="false">
        <div class="card bg-transparent border-white mt-5">
            <div class="card-header brand-gradient border-white">
                <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h5 class="text-white text-uppercase">Invite By Email</h5>

            </div>
            <div class="card-body p-3 pb-5 bg-brand-grey">

                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <label class="text-white col-md-12" for="usern1">Name</label>
                            <div class="col-md-12">
                                <input id="inviteName" class="name-input form-control" type="text"  >
                            </div>
                        </div>
                    </div>
                      ~~~ Truncated for brevity only one input kept for example ~~~~
                </div>
            </div>
        </div>
    </div>
</div>

I have attempted the following solutions:

  1. Moving the modal around to prevent any overlap with "fixed" content.
  2. Playing with z-index values, ensuring the modal has a higher z-index than the backdrop.
  3. Following a guide dated back to 2016 (link to guide) despite its age.
  4. Disabling the backdrop using data-backdrop="false" and adjusting it in my main CSS.
.modal-backdrop {
    /* bug fix - no overlay */
    display: none;
}
  1. Installing a z-index plugin for Chrome to inspect the issue. All z-index values are correct.
  2. Browsing through numerous Stack Overflow threads, attempting both accepted and unaccepted solutions. Despite being adept in css/html, this particular issue is proving challenging.

Answer №1

To create a modal, make sure to include the modal-content class within your modal structure:

Adding via Email

<div class="modal fade" role="dialog" id="inviteByEmailPopup">
  <div class="modal-dialog">
    <div class="modal-content" style="background-color: #404041;">
      <div class="modal-header brand-gradient border-white">
        <div class="brand-gradient border-white">
          <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
          <h5 class="text-white text-uppercase">Invite By Email</h5>
        </div>
      </div>
      <div class="card-body p-3 pb-5 bg-brand-grey">

        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <label class="text-white col-md-12" for="usern1">Name</label>
              <div class="col-md-12">
                <input id="inviteName" class="name-input form-control" type="text"  >
              </div>
            </div>
          </div>
          ~~~ Truncated for brevity only one input kept for example ~~~~
        </div>
      </div>
    </div>
  </div>
</div>

Answer №2

Thanks to the suggestions provided, the issue has been successfully resolved during the troubleshooting process.

It's important to note that when using Bootstrap modal, it is necessary to include

<div class="modal-content">...</div>
within your modal in order to properly wrap the content. Failing to do so can lead to problems with z-index and focus.

I appreciate the assistance given.

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

Challenge with Vite, React, and MSW Integration

Having some trouble setting up MSW in a React application. It's unusual for me to come across issues like this. I've configured an environment variable VITE_MOCK set to true when running the yarn start:mock command. This should enable API mocking ...

Learn the process of applying distinct CSS classes to various elements within an AJAX response

The client initiates an AJAX call via jQuery. Upon fetching data from the database, I return the response which includes the application of numerous classes and styles to various HTML tags. Unfortunately, this process results in code that appears unsightly ...

Leverage nan for the transmission and retrieval of Float32Array within an addon module

I am currently attempting to utilize nan in order to perform calculations on an array of floating point numbers within an add-on and then return the result as a Float32Array. However, while the arguments have IsNumber() and NumberValue() functions, there ...

Why isn't v-model functioning properly in Vue?

In my current project involving an API, I encountered a problem. I utilized axios to fetch data from the API, which returned a JSON array. Each array item had a radio value that I appended to it. Despite attempting to use v-model to track changes in the ra ...

Nested AJAX call yields undefined value

In my Test.vue component, I have a method that is imported into my main.js. I can call its methods like this: this.$refs.test.testMethod(). There is another method in Test.vue called ajaxMethod(), which is defined as follows: function ajaxMethod(){ t ...

php script within a literal .tpl file

Is there a way to perform a json_encode within a literal javascript block in the context of a Smarty template? {literal} <script> function openWin() { var O = {php} echo json_encode($obj);{/php}; // syntax error ...

What Causes the Response to Vary in a Post Request?

Issue: When I use console.log(res.data), it shows different data compared to console.log(JSON.parse(res.request.response)). My Next.js application is sending a post request to an internal API. The response from the REST endpoint should contain a list obje ...

When the div is loaded, automatically navigate to the crucial li element within it, such as the one with the class "import

Welcome to my first webpage: <html> <head> <script type="text/javascript" src="js/jquery.min.js"></script> </head> <body> <div id="comment"></div> <script type="text/ja ...

When activating another function, Javascript failed to trim and hide the div as intended

Before adding another function (*2), my function (*1) was working perfectly. However, after adding the second function, there seems to be a conflict and now it's not working as expected. :( <script type="text/javascript> $(function() { ...

Utilizing the OrientDB HTTP API within an Angular platform - a comprehensive guide

When trying to query OrientDB from an Angular service method, authentication-related errors are encountered. It appears that two GET requests are required for successful querying of OrientDB. An Authentication call: Requesting http://localhost:2480/conne ...

Loading of local resources is restricted in the Apache web server

I am encountering an issue with my Apache web server on a Raspberry Pi. I need to display graphs using the MPLD3 libraries, which are loaded from the server's folder. When I run my index.php page, I receive a Not allowed to load local resources error ...

How can we filter the input type file browse window to display only image files?

I'm trying to figure out how to filter the window popup so that it only shows image files when I click on the input type file. <input type="file" /> Any help would be greatly appreciated as I have been struggling to find a solution for this. ...

An Undefined Session: Leveraging Connect-Redis with ExpressJS and Node.js

Upon waking up this morning, I was greeted with an error message from Nodejitsu: Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process. Determined to find ...

Calculating the total of fields from populated documents using Mongoose

In my application, I have two main models: User and Track. A User can complete various Tracks and earn points for each one. The schema for the User model looks like this: let userSchema = new mongoose.Schema({ name: {type: String, required: true}, ...

Tips on arranging check-boxes horizontally in this code repository

We are working with an autogen form in PHP, and the way the checkboxes are currently displayed is demonstrated in the following code: case FIELD_CHECK_BOX: $fieldHtml = printCheckbox($mode, $field->getId().'[]', $field->get ...

Is there a way to hide a button on this virtual keyboard after it has been clicked?

After creating a virtual keyboard using HTML and CSS, I am looking to implement JavaScript code that will hide a button after it is clicked. Here is the code I have tried so far: function hideButton() { var button = document.getElementById("simple_butto ...

Display or conceal toggle in ruby utilizing jQuery

I'm facing an issue with the functionality of a button that is meant to hide and show a form using jQuery. Initially, I added a path to signup in the button so that it would display and function properly. Now, when I click the button, the form shows u ...

comparison of declarative loop and imperative loop

In my journey to transition from an imperative programming style to a declarative one, I've encountered a challenge related to performance when dealing with loops. Specifically, I have a set of original DATA that I need to manipulate in order to achie ...

Freeze your browser with an Ajax request to a specific URL

There is a function in my view that transfers a value from a text box to a table on the page. This function updates the URL and calls another function called update_verified_phone(). The update_verified_phone() function uses a model called user_info_model( ...

What is the best way to create a loop within a JavaScript function?

I'm having some trouble with looping inside a function. It seems like my looping is not working properly and I need help fixing it, along with suggestions for the problem. :) Here's what I've tried: <script> function getImage1( ...