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
  • #37573
Closed
Open
Issue created Dec 02, 2022 by Administrator@rootContributor2 of 2 checklist items completed2/2 checklist items

Make show/hide/toggle etc a Promise

Created by: aersam

Prerequisites

  • I have searched for duplicate or closed feature requests
  • I have read the contributing guidelines

Proposal

Currently, If I want to do something a after a modal/offcanvas etc has been show, I need to use events:

const myOffcanvas = document.getElementById('myOffcanvas')
myOffcanvas.addEventListener('shown.bs.offcanvas', event => {
  // do something...

  // should probably remove that eventListener if no longer needed
})
myOffcanvas.show()

I would be really nice if something like this worked:

const myOffcanvas = document.getElementById('myOffcanvas')
await myOffcanvas.show()
// do something...

Motivation and context

I think most API's in JavaScript are based on Promises these days , and async-await makes them really simple to use. And since IE is dead, we don't even need a transpiler anymore :)

Also, this would not break existing code as long as the events are still emitted. In addition, it's not required to remove events manually which people sometimes forget to do (at least me)

Assignee
Assign to
Time tracking