Topic: Custom Radio buttons not selectable in a tab-pane

paddymcdonald free asked 5 years ago


I have a radio button group in a tab-pane and they are not selectable

    <div aria-labelledby="tab1" class="tab-pane fade show active" data-toggle="tab" id="pane1" role="tabpanel">
      <div class="card mb-3">
        <div class="card-header">Options in a Nav</div>
        <div class="card-body">
          <div class="form-group">
            <div class="form-row">
              <div class="custom-control custom-radio">
                <input type="radio" class="custom-control-input" id="option1" name="navoption" checked>
                <label class="custom-control-label" for="option1">Option 1</label>
              </div>
            </div>

            <div class="form-row">
              <div class="custom-control custom-radio">
                <input type="radio" class="custom-control-input" id="option2" name="navoption">
                <label class="custom-control-label" for="option2">Option 2</label>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

If the same HTML is included, but not in a tab-pane, it works fine

  <div class="card mb-3">
    <div class="card-header">Options not in a Nav</div>
    <div class="card-body">
      <div class="form-group">
        <div class="form-row">
          <div class="custom-control custom-radio">
            <input type="radio" class="custom-control-input" id="optionA" name="nonnavoption" checked>
            <label class="custom-control-label" for="optionA">Option A</label>
          </div>
        </div>

        <div class="form-row">
          <div class="custom-control custom-radio">
            <input type="radio" class="custom-control-input" id="optionB" name="nonnavoption">
            <label class="custom-control-label" for="optionB">Option B</label>
          </div>
        </div>
      </div>
    </div>
  </div>

Piotr Glejzer staff commented 5 years ago

I think it's a bug. But this is a bootstrap main content so there is a problem probably with their JavaScript code. If you remove data-toggle="tab", everything is working correctly but the tab will not work.


paddymcdonald free commented 5 years ago

Thanks Piotr,

You actually gave me the answer here but I didn't notice it at the time

The solution was to remove the data-toggle="tab" attributes from the tab panels, they are only required on the nav (which I did not include in the example)

Regards,

Patrick



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.7.4
  • Device: Desktop
  • Browser: Chrome
  • OS: Window 7
  • Provided sample code: No
  • Provided link: No