Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
djthorpe opened this issue Apr 6, 2021 · 4 comments · Fixed by #33545
Closed

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

djthorpe opened this issue Apr 6, 2021 · 4 comments · Fixed by #33545
Labels

Comments

@djthorpe
Copy link

djthorpe commented Apr 6, 2021

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>
@GeoSot
Copy link
Member

GeoSot commented Apr 6, 2021

@djthorpe pleasecan you provide a codepen example?

@djthorpe
Copy link
Author

djthorpe commented Apr 7, 2021

Yep apologies - here is the example on codepen:

https://codepen.io/djthorpe/pen/vYgeOVo

@GeoSot
Copy link
Member

GeoSot commented Apr 7, 2021

Very interesting. I suspect the already created offcanvas catches the 'click' event and closes itself.

I am pretty sure, is going to be fixed with #33545

Stay in touch please

Demo codepen

@XhmikosR XhmikosR changed the title Offcanvas doesn't show when calling show() programatically Offcanvas doesn't show when calling show() programmatically Apr 9, 2021
@kinduff
Copy link

kinduff commented Apr 28, 2021

This fixed the issue I was also facing, but had to add an e.stopPropagation(); in order to make it work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants