@momentum-design/components 0.84.4 → 0.85.0

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.
@@ -142,8 +142,13 @@ declare class Dialog extends Dialog_base {
142
142
  */
143
143
  disableAriaHasPopup: boolean;
144
144
  /**
145
- * For now FocusTrap is always true as the dialog is a modal component only.
146
- * This means it will always trap focus within the dialog when it is open.
145
+ * Determines whether the focus trap is enabled.
146
+ * If true, focus will be restricted to the content within this component.
147
+ *
148
+ * NOTE: this should only be disabled in rare cases! By default a Modal Dialog
149
+ * should trap focus always.
150
+ *
151
+ * @default true
147
152
  */
148
153
  focusTrap: boolean;
149
154
  /**
@@ -147,10 +147,15 @@ class Dialog extends PreventScrollMixin(FocusTrapMixin(CardAndDialogFooterMixin(
147
147
  */
148
148
  this.disableAriaHasPopup = DEFAULTS.DISABLE_ARIA_HAS_POPUP;
149
149
  /**
150
- * For now FocusTrap is always true as the dialog is a modal component only.
151
- * This means it will always trap focus within the dialog when it is open.
150
+ * Determines whether the focus trap is enabled.
151
+ * If true, focus will be restricted to the content within this component.
152
+ *
153
+ * NOTE: this should only be disabled in rare cases! By default a Modal Dialog
154
+ * should trap focus always.
155
+ *
156
+ * @default true
152
157
  */
153
- this.focusTrap = true;
158
+ this.focusTrap = DEFAULTS.FOCUS_TRAP;
154
159
  /**
155
160
  * For now preventScroll is always true as the dialog is a modal component only.
156
161
  * This means scroll will be prevented when the dialog is open.
@@ -328,7 +333,9 @@ class Dialog extends PreventScrollMixin(FocusTrapMixin(CardAndDialogFooterMixin(
328
333
  this.createBackdrop();
329
334
  this.activatePreventScroll();
330
335
  await this.updateComplete;
331
- (_a = this.activateFocusTrap) === null || _a === void 0 ? void 0 : _a.call(this);
336
+ if (this.focusTrap) {
337
+ (_a = this.activateFocusTrap) === null || _a === void 0 ? void 0 : _a.call(this);
338
+ }
332
339
  (_b = this.setInitialFocus) === null || _b === void 0 ? void 0 : _b.call(this);
333
340
  // Set aria-expanded attribute on the trigger element to true if it exists
334
341
  (_c = this.triggerElement) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-expanded', 'true');
@@ -470,4 +477,8 @@ __decorate([
470
477
  property({ type: Boolean, reflect: true, attribute: 'disable-aria-haspopup' }),
471
478
  __metadata("design:type", Boolean)
472
479
  ], Dialog.prototype, "disableAriaHasPopup", void 0);
480
+ __decorate([
481
+ property({ type: Boolean, reflect: true, attribute: 'focus-trap' }),
482
+ __metadata("design:type", Boolean)
483
+ ], Dialog.prototype, "focusTrap", void 0);
473
484
  export default Dialog;
@@ -13,6 +13,7 @@ declare const DEFAULTS: {
13
13
  readonly CANCEL_ICON: "cancel-bold";
14
14
  readonly VARIANT: "default";
15
15
  readonly DISABLE_ARIA_HAS_POPUP: false;
16
+ readonly FOCUS_TRAP: true;
16
17
  };
17
18
  declare const DIALOG_SIZE: readonly ["small", "medium", "large"];
18
19
  declare const DIALOG_ROLE: readonly ["dialog", "alertdialog"];
@@ -14,6 +14,7 @@ const DEFAULTS = {
14
14
  CANCEL_ICON: 'cancel-bold',
15
15
  VARIANT: DIALOG_VARIANT.DEFAULT,
16
16
  DISABLE_ARIA_HAS_POPUP: false,
17
+ FOCUS_TRAP: true,
17
18
  };
18
19
  const DIALOG_SIZE = ['small', 'medium', 'large'];
19
20
  const DIALOG_ROLE = ['dialog', 'alertdialog'];