@open-rlb/ng-bootstrap 2.4.7 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2069,11 +2069,13 @@ class ModalDirective {
|
|
|
2069
2069
|
this.el = el;
|
|
2070
2070
|
this.renderer = renderer;
|
|
2071
2071
|
this.innerModalService = innerModalService;
|
|
2072
|
+
this.triggerElement = null;
|
|
2072
2073
|
this._openChange_f = (e) => {
|
|
2073
2074
|
this.innerModalService.eventModal(e.type.replace('.bs.modal', ''), this._modalReason, this.id, this.instance?.result);
|
|
2074
2075
|
};
|
|
2075
2076
|
}
|
|
2076
2077
|
ngOnInit() {
|
|
2078
|
+
this.triggerElement = document.activeElement;
|
|
2077
2079
|
// Check prop existence
|
|
2078
2080
|
// This approach permits to handle empty string '' case
|
|
2079
2081
|
const hasContent = Object.prototype.hasOwnProperty.call(this.instance.data, 'content') &&
|
|
@@ -2166,6 +2168,7 @@ class ModalDirective {
|
|
|
2166
2168
|
this._modalReason = reason;
|
|
2167
2169
|
}
|
|
2168
2170
|
this.bsModal?.hide();
|
|
2171
|
+
this.triggerElement?.focus();
|
|
2169
2172
|
}
|
|
2170
2173
|
initButtons() {
|
|
2171
2174
|
this._reasonButtons = this.contentElement.querySelectorAll('[data-modal-reason]');
|
|
@@ -2175,10 +2178,12 @@ class ModalDirective {
|
|
|
2175
2178
|
this._modalReason = btn.getAttribute('data-modal-reason');
|
|
2176
2179
|
if (this._modalReason === 'cancel' || this._modalReason === 'close') {
|
|
2177
2180
|
this.bsModal?.hide();
|
|
2181
|
+
this.triggerElement?.focus();
|
|
2178
2182
|
}
|
|
2179
2183
|
if (this._modalReason === 'ok') {
|
|
2180
2184
|
if (this.instance.valid) {
|
|
2181
2185
|
this.bsModal?.hide();
|
|
2186
|
+
this.triggerElement?.focus();
|
|
2182
2187
|
}
|
|
2183
2188
|
}
|
|
2184
2189
|
});
|