Skip to content
GitLab
    • Explore Projects Groups Snippets
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
  • Merge requests
  • !24572

Do not create a Popper.js instance when we don't need it

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge v4-dev-johann-dropdown-navbar-without-popper into v4-dev 7 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: Johann-S

Why did I change that ? Because maybe if we find a solution to just warn user instead of throwing an error a breaking our entire JS, folks will be able to use our Dropdown in a navbar without Popper.js

Compare
  • v4-dev (base)

and
  • latest version
    10fd994f
    1 commit, 2 years ago

1 file
+ 18
- 21

    Preferences

    File browser
    Compare changes
js/src/dropdown.js
+ 18
- 21
  • View file @ 10fd994f

  • Edit in single-file editor

  • Open in Web IDE


@@ -143,22 +143,25 @@ const Dropdown = (($) => {
return
}
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)')
}
let element = this._element
// for dropup with alignment we use the parent as popper container
if ($(parent).hasClass(ClassName.DROPUP)) {
if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
element = parent
// Disable totally Popper.js for Dropdown in Navbar
if (!this._inNavbar) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)')
}
let element = this._element
// for dropup with alignment we use the parent as popper container
if ($(parent).hasClass(ClassName.DROPUP)) {
if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
element = parent
}
}
this._popper = new Popper(element, this._menu, this._getPopperConfig())
}
this._popper = new Popper(element, this._menu, this._getPopperConfig())
// if this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
@@ -185,8 +188,8 @@ const Dropdown = (($) => {
this._menu = null
if (this._popper !== null) {
this._popper.destroy()
this._popper = null
}
this._popper = null
}
update() {
@@ -275,12 +278,6 @@ const Dropdown = (($) => {
}
}
// Disable Popper.js for Dropdown in Navbar
if (this._inNavbar) {
popperConfig.modifiers.applyStyle = {
enabled: !this._inNavbar
}
}
return popperConfig
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: firstcontributions/first-contributions!65096
Source branch: v4-dev-johann-dropdown-navbar-without-popper

Menu

Explore Projects Groups Snippets