Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dismiss trigger issues #1822

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/js/autoinit/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SelectorEngine from "../dom/selector-engine";
import { enableDismissTrigger } from "../util/component-functions";
import jqueryInit from "./jqueryInit";
import {
dropdownCallback,
Expand All @@ -25,6 +26,7 @@ const defaultInitSelectors = {
name: "Alert",
selector: "[data-te-alert-init]",
isToggler: false,
dismissMethod: "close",
},
animation: {
name: "Animate",
Expand Down Expand Up @@ -95,6 +97,7 @@ const defaultInitSelectors = {
name: "Toast",
selector: "[data-te-toast-init]",
isToggler: false,
dismissMethod: "hide",
},
datatable: {
name: "Datatable",
Expand Down Expand Up @@ -131,6 +134,7 @@ const defaultInitSelectors = {
modal: {
name: "Modal",
selector: "[data-te-toggle='modal']",
dismissMethod: "hide",
isToggler: true,
callback: modalCallback,
},
Expand All @@ -143,6 +147,7 @@ const defaultInitSelectors = {
offcanvas: {
name: "Offcanvas",
selector: "[data-te-offcanvas-toggle]",
dismissMethod: "hide",
isToggler: true,
callback: offcanvasCallback,
},
Expand Down Expand Up @@ -183,6 +188,10 @@ const initComponent = (component) => {

jqueryInit(component);

if (thisComponent?.dismissMethod) {
enableDismissTrigger(component, thisComponent.dismissMethod);
}

if (thisComponent?.advanced) {
thisComponent?.advanced(component, thisComponent?.selector);
return;
Expand Down
11 changes: 0 additions & 11 deletions src/js/components/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { typeCheckConfig, isVisible } from "../util/index";
import EventHandler from "../dom/event-handler";
import BaseComponent from "../base-component";
import Manipulator from "../dom/manipulator";
import { enableDismissTrigger } from "../util/component-functions";

/*
------------------------------------------------------------------------
Expand Down Expand Up @@ -66,8 +65,6 @@ class Alert extends BaseComponent {
this._element = element;
this._config = this._getConfig(config);
this._classes = this._getClasses(classes);
this._didInit = false;
this._init();
}

// Getters
Expand Down Expand Up @@ -163,14 +160,6 @@ class Alert extends BaseComponent {
}

// Private
_init() {
if (this._didInit) {
return;
}
enableDismissTrigger(Alert, "close");
this._didInit = true;
}

_getConfig(config) {
config = {
...Default,
Expand Down
13 changes: 0 additions & 13 deletions src/js/components/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import ScrollBarHelper from "../util/scrollbar";
import BaseComponent from "../base-component";
import Backdrop from "../util/backdrop";
import FocusTrap from "../util/focusTrap";
import { enableDismissTrigger } from "../util/component-functions";

/*
------------------------------------------------------------------------
Expand Down Expand Up @@ -89,8 +88,6 @@ class Modal extends BaseComponent {
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollBar = new ScrollBarHelper();
this._didInit = false;
this._init();
}

// Getters
Expand Down Expand Up @@ -195,16 +192,6 @@ class Modal extends BaseComponent {
}

// Private
_init() {
if (this._didInit) {
return;
}

enableDismissTrigger(Modal);

this._didInit = true;
}

_initializeBackDrop() {
return new Backdrop({
isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value
Expand Down
2 changes: 0 additions & 2 deletions src/js/components/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SelectorEngine from "../dom/selector-engine";
import Manipulator from "../dom/manipulator";
import Backdrop from "../util/backdrop";
import FocusTrap from "../util/focusTrap";
import { enableDismissTrigger } from "../util/component-functions";

/*
------------------------------------------------------------------------
Expand Down Expand Up @@ -177,7 +176,6 @@ class Offcanvas extends BaseComponent {
)
);

enableDismissTrigger(Offcanvas);
this._didInit = true;
}

Expand Down
12 changes: 0 additions & 12 deletions src/js/components/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { reflow, typeCheckConfig } from "../util/index";
import EventHandler from "../dom/event-handler";
import Manipulator from "../dom/manipulator";
import BaseComponent from "../base-component";
import { enableDismissTrigger } from "../util/component-functions";

/*
------------------------------------------------------------------------
Expand Down Expand Up @@ -78,8 +77,6 @@ class Toast extends BaseComponent {
this._hasMouseInteraction = false;
this._hasKeyboardInteraction = false;
this._setListeners();
this._didInit = false;
this._init();
}

// Getters
Expand Down Expand Up @@ -168,15 +165,6 @@ class Toast extends BaseComponent {
}

// Private
_init() {
if (this._didInit) {
return;
}

enableDismissTrigger(Toast);
this._didInit = true;
}

_getConfig(config) {
config = {
...Default,
Expand Down