Fixed bootstrap-selectpickers on bootstrap 5

This commit is contained in:
Jan Böhmer 2022-07-24 20:23:12 +02:00
parent 5d6f244e71
commit 489f4b939a
5 changed files with 24 additions and 24 deletions

View file

@ -1,6 +1,9 @@
const bootstrap = window.bootstrap = require('bootstrap'); // without this bootstrap-select crashes with `undefined bootstrap`
require('bootstrap-select/js/bootstrap-select'); // we have to manually require the working js file
import {Controller} from "@hotwired/stimulus";
import "bootstrap-select";
import 'bootstrap-select/dist/css/bootstrap-select.css'
//import "bootstrap-select/js/bootstrap-select";
import 'bootstrap-select/sass/bootstrap-select.scss';
export default class extends Controller {
connect() {

View file

@ -30,7 +30,8 @@ const RegisterEventHelper = class {
registerTooltips() {
this.registerLoadHandler(() => {
$(".tooltip").remove();
$('a[title], button[title], span[title], h6[title], h3[title], i.fas[title]')
//Exclude dropdown buttons from tooltips, otherwise we run into endless errors from bootstrap (bootstrap.esm.js:614 Bootstrap doesn't allow more than one instance per element. Bound instance: bs.dropdown.)
$('a[title], button[title]:not([data-bs-toggle="dropdown"]), span[title], h6[title], h3[title], i.fas[title]')
//@ts-ignore
.tooltip("hide").tooltip({container: "body", placement: "auto", boundary: 'window'});
});

View file

@ -28,7 +28,7 @@
"@zxing/library": "^0.19.1",
"bootbox": "^5.4.0",
"bootstrap-fileinput": "^5.0.1",
"bootstrap-select": "^1.13.8",
"bootstrap-select": "v1.14.0-beta3",
"bootswatch": "^5.1.3",
"bs-custom-file-input": "^1.3.4",
"clipboard": "^2.0.4",

View file

@ -115,3 +115,14 @@
{%- endif -%}
{%- endblock tristate_widget %}
{%- block choice_widget_collapsed -%}
{# Only add the BS5 form-select class if we dont use bootstrap-selectpicker #}
{% if attr["data-controller"] is defined and attr["data-controller"] != "elements--selectpicker" %}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-select')|trim}) -%}
{% else %}
{# If it is an selectpicker add form-control class to fill whole width #}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%}
{% endif %}
{{- block("choice_widget_collapsed", "bootstrap_base_layout.html.twig") -}}
{%- endblock choice_widget_collapsed -%}

View file

@ -1121,21 +1121,6 @@
dependencies:
"@types/node" "*"
"@types/bootbox@^5.2.0":
version "5.2.3"
resolved "https://registry.yarnpkg.com/@types/bootbox/-/bootbox-5.2.3.tgz#86aa918eb4df2499631887bb7b6b23f0195a751d"
integrity sha512-6O9474usap0SRkRhPYhmtrAWPfQ2Kwb5WsSxVkM8uT5FwRp/TQijSrhg344r+zJb4K38b96DlXaqs/BrW4Banw==
dependencies:
"@types/jquery" "*"
"@types/bootstrap@^4.3.0":
version "4.6.2"
resolved "https://registry.yarnpkg.com/@types/bootstrap/-/bootstrap-4.6.2.tgz#84d4dd3ee41e903c7bc17e47b9997ec804d8d64e"
integrity sha512-HbqVAre9VMZF8KBw1UpmBkw0xt4rjrAxMO/JWqFfJZGbVi09t8BVccvB/VxDlygVvvu0BZkAU8ocfNc7/jlFsA==
dependencies:
"@types/jquery" "*"
popper.js "^1.14.1"
"@types/connect-history-api-fallback@^1.3.5":
version "1.3.5"
resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae"
@ -1755,10 +1740,10 @@ bootstrap-fileinput@^5.0.1:
jquery ">= 1.9.0"
opencollective-postinstall "^2.0.2"
bootstrap-select@^1.13.8:
version "1.13.18"
resolved "https://registry.yarnpkg.com/bootstrap-select/-/bootstrap-select-1.13.18.tgz#4557119d58dc1159189977161c803962220e4dda"
integrity sha512-V1IzK4rxBq5FrJtkzSH6RmFLFBsjx50byFbfAf8jYyXROWs7ZpprGjdHeoyq2HSsHyjJhMMwjsQhRoYAfxCGow==
bootstrap-select@v1.14.0-beta3:
version "1.14.0-beta3"
resolved "https://registry.yarnpkg.com/bootstrap-select/-/bootstrap-select-1.14.0-beta3.tgz#dc15083fe51d0ac7b38a3b99dfd492dcc0a783b0"
integrity sha512-wYUDY4NAYBcNydXybE7wh3+ucyf+AcUOhZ+e0TFIoZ38A+k/3BVT1RPl5f0CiPxAexP1IQuqALKMqI8wtZS71A==
"bootstrap@>= 3.4.1", bootstrap@^5.1.3:
version "5.2.0"
@ -4022,7 +4007,7 @@ png-js@^1.0.0:
resolved "https://registry.yarnpkg.com/png-js/-/png-js-1.0.0.tgz#e5484f1e8156996e383aceebb3789fd75df1874d"
integrity sha512-k+YsbhpA9e+EFfKjTCH3VW6aoKlyNYI6NYdTfDL4CIvFnvsuO84ttonmZE7rc+v23SLTH8XX+5w/Ak9v0xGY4g==
popper.js@^1.14.1, popper.js@^1.14.7:
popper.js@^1.14.7:
version "1.16.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==