Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #33372
Closed
Open
Issue created Mar 15, 2021 by Administrator@rootContributor

v5 Offcanvas: Not visible on page load with show class

Created by: iainhallam

Operating system and version: Windows 10 Browser and version: Firefox 86.0 and Chome 89.0.4389.82

I'm trying out the new offcanvas component, which is great, but when I have show as part of the initial classes, the menu doesn't open on page load. It may be something I'm doing wrong, but I think I've followed the setup correctly for the current Bootstrap from GitHub.

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/bootstrap.css">
        <title>Offcanvas test</title>
    </head>
    <body>
        <div id="app-menu" class="offcanvas offcanvas-start show">
            <h2>Offcanvas</h2>
        </div>
        <button class="btn" type="button" data-bs-toggle="offcanvas" data-bs-target="#app-menu">
            Open menu
        </button>
        <script src="js/bootstrap.bundle.js"></script>
    </body>
</html>

Expected behaviour: On load, the offcanvas is opened, and the document obscured by the overlay.

Actual behaviour: No offcanvas shown. Clicking the button the first time does nothing (it toggles the show class off), then the second time it shows the offcanvas and the document is obscured.

Moving the script tag to the top of the document or into the head seems to make no difference.

Assignee
Assign to
Time tracking