@mediafly/js-ui 51.5.1-1 → 51.5.1-3
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.
|
@@ -18,7 +18,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
18
18
|
modalHeaderClass?: string | undefined;
|
|
19
19
|
modalSize?: 'large' | 'full' | undefined;
|
|
20
20
|
modalId: string | undefined;
|
|
21
|
-
|
|
21
|
+
modalAsyncContentLoaded?: boolean | undefined;
|
|
22
22
|
modalCloseCallback: () => void;
|
|
23
23
|
/** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
|
|
24
24
|
modalConfirmDismissCallback?: () => ModalDismissConfirmation | undefined;
|
|
@@ -30,6 +30,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
30
30
|
private keyDownHandler;
|
|
31
31
|
private lastFocusable;
|
|
32
32
|
private modalElement;
|
|
33
|
+
private hasAppliedFirstFocus;
|
|
33
34
|
constructor($attrs: ng.IAttributes, $element: ng.IAugmentedJQuery, $timeout: ng.ITimeoutService, $transclude: ng.ITranscludeFunction, $window: ng.IWindowService, mflyModalService: MflyModalService);
|
|
34
35
|
$onDestroy(): void;
|
|
35
36
|
$onInit(): void;
|
|
@@ -26,6 +26,7 @@ let MflyModalComponentController = class MflyModalComponentController {
|
|
|
26
26
|
this.$transclude = $transclude;
|
|
27
27
|
this.$window = $window;
|
|
28
28
|
this.mflyModalService = mflyModalService;
|
|
29
|
+
this.hasAppliedFirstFocus = false;
|
|
29
30
|
}
|
|
30
31
|
$onDestroy() {
|
|
31
32
|
this.$window.removeEventListener('keydown', this.keyDownHandler);
|
|
@@ -38,7 +39,7 @@ let MflyModalComponentController = class MflyModalComponentController {
|
|
|
38
39
|
this.$window.addEventListener('keydown', this.keyDownHandler);
|
|
39
40
|
// Set up an observer for disabledness changes so that our focus trap will update itself.
|
|
40
41
|
const observer = new MutationObserver(mutations => {
|
|
41
|
-
mutations.forEach(lodash_1.default.debounce(() => this.calculateFocusableElements(), 50));
|
|
42
|
+
mutations.forEach(lodash_1.default.debounce(() => this.calculateFocusableElements(true), 50));
|
|
42
43
|
});
|
|
43
44
|
observer.observe(this.$element[0], {
|
|
44
45
|
attributes: true,
|
|
@@ -66,11 +67,12 @@ let MflyModalComponentController = class MflyModalComponentController {
|
|
|
66
67
|
this.$timeout(() => {
|
|
67
68
|
var _a;
|
|
68
69
|
this.$element.find('.c-modal__backdrop').addClass('is-visible');
|
|
69
|
-
if (this.
|
|
70
|
+
if (this.modalAsyncContentLoaded === false) {
|
|
70
71
|
(_a = this.modalElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
if (this.modalAsyncContentLoaded === undefined) {
|
|
73
74
|
this.firstFocusable.focus();
|
|
75
|
+
this.hasAppliedFirstFocus = true;
|
|
74
76
|
}
|
|
75
77
|
}, 50);
|
|
76
78
|
}
|
|
@@ -118,7 +120,7 @@ let MflyModalComponentController = class MflyModalComponentController {
|
|
|
118
120
|
event.preventDefault();
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
calculateFocusableElements() {
|
|
123
|
+
calculateFocusableElements(checkAsyncLoadFocus = false) {
|
|
122
124
|
const selectors = [
|
|
123
125
|
'[href]',
|
|
124
126
|
'[tabindex]:not([tabindex="-1"])',
|
|
@@ -136,6 +138,10 @@ let MflyModalComponentController = class MflyModalComponentController {
|
|
|
136
138
|
this.focusableElementsInModal = this.$element.find(selectors.join(','));
|
|
137
139
|
this.firstFocusable = this.focusableElementsInModal[0];
|
|
138
140
|
this.lastFocusable = this.focusableElementsInModal[this.focusableElementsInModal.length - 1];
|
|
141
|
+
if (checkAsyncLoadFocus && this.modalAsyncContentLoaded && !this.hasAppliedFirstFocus) {
|
|
142
|
+
this.firstFocusable.focus();
|
|
143
|
+
this.hasAppliedFirstFocus = true;
|
|
144
|
+
}
|
|
139
145
|
}
|
|
140
146
|
};
|
|
141
147
|
__decorate([
|
|
@@ -157,7 +163,7 @@ __decorate([
|
|
|
157
163
|
__decorate([
|
|
158
164
|
decorators_1.Input('@'),
|
|
159
165
|
__metadata("design:type", Object)
|
|
160
|
-
], MflyModalComponentController.prototype, "
|
|
166
|
+
], MflyModalComponentController.prototype, "modalAsyncContentLoaded", void 0);
|
|
161
167
|
__decorate([
|
|
162
168
|
decorators_1.Output(),
|
|
163
169
|
__metadata("design:type", Function)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.component.js","sourceRoot":"","sources":["../../src/components/modal/modal.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,oDAAsB;AACtB,8CAAgE;AAChE,oEAA8C;AAkB9C,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;
|
|
1
|
+
{"version":3,"file":"modal.component.js","sourceRoot":"","sources":["../../src/components/modal/modal.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,oDAAsB;AACtB,8CAAgE;AAChE,oEAA8C;AAkB9C,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;IAuBhD,YAC2B,MAAsB,EACpB,QAA6B,EAC7B,QAA4B,EACzB,WAAmC,EACvC,OAA0B,EACjB,gBAAkC;QAL5C,WAAM,GAAN,MAAM,CAAgB;QACpB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,aAAQ,GAAR,QAAQ,CAAoB;QACzB,gBAAW,GAAX,WAAW,CAAwB;QACvC,YAAO,GAAP,OAAO,CAAmB;QACjB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAR/D,yBAAoB,GAAY,KAAK,CAAA;IASzC,CAAC;IAEL,UAAU;QAET,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;QAChE,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAA;IACnC,CAAC;IAED,OAAO;QAEN,IAAI,CAAC,qBAAqB,GAA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CAAC,CAAA;IAChB,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,aAAa,CAAC,CAAA;IACrB,WAAA,mBAAM,CAAC,SAAS,CAAC,CAAA;IACjB,WAAA,mBAAM,CAAC,kBAAkB,CAAC,CAAA;iFAA2B,uBAAgB;GA7BnD,4BAA4B,CA8KhD;kBA9KoB,4BAA4B"}
|
|
@@ -1197,8 +1197,8 @@
|
|
|
1197
1197
|
"affectsGlobalScope": false
|
|
1198
1198
|
},
|
|
1199
1199
|
"../src/components/modal/modal.component.ts": {
|
|
1200
|
-
"version": "
|
|
1201
|
-
"signature": "
|
|
1200
|
+
"version": "3c5d9ec85b1e32b4ad1514b98d6098867c041a91e4588395ebdab83eb3b1de86",
|
|
1201
|
+
"signature": "400522d47c4656c314a81721c582feb467f206e2049680075e144fe70700f00b",
|
|
1202
1202
|
"affectsGlobalScope": false
|
|
1203
1203
|
},
|
|
1204
1204
|
"../src/components/modal/index.ts": {
|
package/package.json
CHANGED
|
@@ -25,9 +25,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
25
25
|
@Input('@') modalHeaderClass?: string | undefined
|
|
26
26
|
@Input('@') modalSize?: 'large' | 'full' | undefined
|
|
27
27
|
@Input('@') modalId: string | undefined
|
|
28
|
-
|
|
29
|
-
// It is primarily for use by modals that load their content asynchronously.
|
|
30
|
-
@Input('@') focusModal?: boolean | undefined
|
|
28
|
+
@Input('@') modalAsyncContentLoaded?: boolean | undefined
|
|
31
29
|
|
|
32
30
|
@Output() modalCloseCallback: () => void
|
|
33
31
|
/** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
|
|
@@ -42,6 +40,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
42
40
|
private keyDownHandler: (event: KeyboardEvent) => void
|
|
43
41
|
private lastFocusable: HTMLElement
|
|
44
42
|
private modalElement: HTMLElement
|
|
43
|
+
private hasAppliedFirstFocus: boolean = false
|
|
45
44
|
|
|
46
45
|
constructor(
|
|
47
46
|
@Inject('$attrs') private $attrs: ng.IAttributes,
|
|
@@ -68,7 +67,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
68
67
|
|
|
69
68
|
// Set up an observer for disabledness changes so that our focus trap will update itself.
|
|
70
69
|
const observer = new MutationObserver(mutations => {
|
|
71
|
-
mutations.forEach(_.debounce(() => this.calculateFocusableElements(), 50))
|
|
70
|
+
mutations.forEach(_.debounce(() => this.calculateFocusableElements(true), 50))
|
|
72
71
|
})
|
|
73
72
|
|
|
74
73
|
observer.observe(this.$element[0], {
|
|
@@ -102,10 +101,12 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
102
101
|
// Timeout 0 only intermittently fires the animation; 50ms seems to be reliable.
|
|
103
102
|
this.$timeout(() => {
|
|
104
103
|
this.$element.find('.c-modal__backdrop').addClass('is-visible')
|
|
105
|
-
if (this.
|
|
104
|
+
if (this.modalAsyncContentLoaded === false) {
|
|
106
105
|
this.modalElement?.focus()
|
|
107
|
-
}
|
|
106
|
+
}
|
|
107
|
+
if (this.modalAsyncContentLoaded === undefined) {
|
|
108
108
|
this.firstFocusable.focus()
|
|
109
|
+
this.hasAppliedFirstFocus = true
|
|
109
110
|
}
|
|
110
111
|
}, 50)
|
|
111
112
|
}
|
|
@@ -168,7 +169,7 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
private calculateFocusableElements() {
|
|
172
|
+
private calculateFocusableElements(checkAsyncLoadFocus: boolean = false) {
|
|
172
173
|
|
|
173
174
|
const selectors = [
|
|
174
175
|
'[href]',
|
|
@@ -186,5 +187,10 @@ export default class MflyModalComponentController implements IComponentControlle
|
|
|
186
187
|
this.focusableElementsInModal = this.$element.find(selectors.join(','))
|
|
187
188
|
this.firstFocusable = this.focusableElementsInModal[0]
|
|
188
189
|
this.lastFocusable = this.focusableElementsInModal[this.focusableElementsInModal.length - 1]
|
|
190
|
+
|
|
191
|
+
if (checkAsyncLoadFocus && this.modalAsyncContentLoaded && !this.hasAppliedFirstFocus) {
|
|
192
|
+
this.firstFocusable.focus()
|
|
193
|
+
this.hasAppliedFirstFocus = true
|
|
194
|
+
}
|
|
189
195
|
}
|
|
190
196
|
}
|