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

New Toast.isShown() method

Created by: khalyomede

Prerequisites

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

Proposal

import { Toast } from "bootstrap";

const element = document.getElementById("toast");

if (element instanceof HTMLElement) {
  const toast = new Toast(element);

  // Before
  if (!element.classList.contains("show")) {
    toast.show();
  }

  // after
  if (!toast.isShown()) {
    toast.show();
  }
}

Motivation and context

I would like to prevent the user to see new animation of the toast if he clicks multiple time to show the same toast.

I do not know how to import the "CLASS_NAME_SHOW" (https://github.com/twbs/bootstrap/blob/main/js/src/toast.js#L32) constant, and it feels like this is not safe to rely on the "show" class name.

On the other hand, having a Toast.isShown() method would ensure future major upgrade can safely change the "show" class name without affecting the end-developper result (supposing the documentation clearly enforce to use Toast.isShown()).

Assignee
Assign to
Time tracking