@brightspace-ui/core 3.280.3 → 3.280.4

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.
@@ -80,7 +80,6 @@ class Form extends LocalizeCoreElement(LitElement) {
80
80
 
81
81
  connectedCallback() {
82
82
  super.connectedCallback();
83
- window.addEventListener('beforeunload', this.#onUnload);
84
83
  /** @ignore */
85
84
  this._isSubForm = !this.dispatchEvent(new CustomEvent('d2l-form-connect', { bubbles: true, composed: true, cancelable: true }));
86
85
  }
@@ -286,7 +285,10 @@ class Form extends LocalizeCoreElement(LitElement) {
286
285
  const ele = e.target;
287
286
 
288
287
  if ((isNativeFormElement(ele) || isCustomFormElement(ele)) && e.type !== 'focusout') {
289
- this._dirty = true;
288
+ if (!this._dirty) {
289
+ window.addEventListener('beforeunload', this.#onUnload);
290
+ this._dirty = true;
291
+ }
290
292
  /** Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not. */
291
293
  this.dispatchEvent(new CustomEvent('d2l-form-dirty'));
292
294
  }
@@ -312,6 +314,7 @@ class Form extends LocalizeCoreElement(LitElement) {
312
314
  }
313
315
 
314
316
  async _submitData(submitter) {
317
+ window.removeEventListener('beforeunload', this.#onUnload);
315
318
  this._dirty = false;
316
319
 
317
320
  let formData = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.280.3",
3
+ "version": "3.280.4",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",