0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Dropdown: use a better selector to avoid triggering click if button is disabled (#35866)

This commit is contained in:
GeoSot 2022-02-19 16:22:32 +02:00 committed by GitHub
parent 353ad45b4b
commit cb8726d9e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,7 @@ const CLASS_NAME_DROPUP = 'dropup'
const CLASS_NAME_DROPEND = 'dropend' const CLASS_NAME_DROPEND = 'dropend'
const CLASS_NAME_DROPSTART = 'dropstart' const CLASS_NAME_DROPSTART = 'dropstart'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]' const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)'
const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}` const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`
const SELECTOR_MENU = '.dropdown-menu' const SELECTOR_MENU = '.dropdown-menu'
const SELECTOR_NAVBAR = '.navbar' const SELECTOR_NAVBAR = '.navbar'
@ -407,10 +407,6 @@ class Dropdown extends BaseComponent {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
if (isDisabled(this)) {
return
}
const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, delegateTarget.parentNode) const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, delegateTarget.parentNode)
const instance = Dropdown.getOrCreateInstance(getToggleButton) const instance = Dropdown.getOrCreateInstance(getToggleButton)