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

Allow changing modal options after creation

Created by: RentecTravis

Prerequisites

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

Proposal

Given a dismissible modal (created with the options `{backdrop: true, keyboard: true}'), some way to change the options after creation, to disable closing the modal, would be welcome.

Right now, in Bootstrap 5 you can modify a modal object's _config properties. But you shouldn't, because those properties are not meant to be consistently available across minor versions. They may technically be public in scope but are not part of the public API.

What would be ideal is a public-API method for updating configuration. Something like, modal.config(options: {}). I like that because config() fits with some of the other method names like show(), hide(), toggle(). However a name like setOptions() may be clearer.

In any case, usage would look like this:

const el = document.getElementById('modal')
const modal = bootstrap.Modal.getOrCreateInstance(el)

modal.show()
// ...

// now when you want to prevent closing the modal
modal.config{{
  backdrop: 'static',
  keyboard: false,
})

Motivation and context

In my case the need for this arose from our having a Bootstrap modal which contained a two-step form. At the end of the form, we needed users to say "yes, this worked", or "no, start over"

Selecting yes logs their response and closes the modal. Selecting "no" takes them back to the first step.

If the user can just click the backdrop, or hit Esc to close the modal, they get confused because they can't find the result in their records. If we disable closing the modal from the beginning, then they have no way to leave.

Assignee
Assign to
Time tracking