Till this MR:
-
plugins that support dismiss action by clicking on a
data-bs-dismiss
trigger, can be dismissed ONLY if the trigger is inside the plugin html. -
Alert, makes the difference. Alert on
data-bs-dismiss
click, tries to parse adata-bs-target
element and in case in null, it fallback on the standard way, that assumes the trigger is inside the plugin html
This MR:
introduces the enableDismissTrigger
helper function, that streamlines the functionality, using the idea of Alert component.
When 'dismiss' is clicked, it searches for getElementFromSelector(event.target) || this.closest(
.${Plugin.NAME})
.
Result:
- The dismiss trigger can be either inside the component, or with the use of
data-bs-target
it can be anywhere in doc - the dismiss trigger will respect the disable state and will handle preventDefault in case it is an anchor
The idea came from #33324 (closed)