Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Offcanvas doesn't show when calling show() programmatically #33564

@djthorpe

Description

@djthorpe

Version:
bootstrap-5.0.0-beta3

Browser:
Google Chrome (on MacOS) 89.0.4389.114

Issue:
Calling show() programatically does not show canvas, only backdrop appears for a moment then disappears

Javascript Class implemented:

class InfoView {
    constructor() {
        var node = document.querySelector("#infosheet");
        this._Modal = new bootstrap.Offcanvas(node);
    }
    doShow() {
            this._Modal.show();
    }
}

HTML implemented:

   <div class="offcanvas offcanvas-bottom" tabindex="-1" id="infosheet" aria-labelledby="info-label">
        <div class="offcanvas-header">
          <h5 class="offcanvas-title" id="info-label">Offcanvas Bottom</h5>
          <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="offcanvas-body small">
          ...
        </div>
    </div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions