phoenix_live_view 1.0.3 → 1.0.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.
@@ -1139,9 +1139,11 @@ var Hooks = {
1139
1139
  aria_default.focusFirst(this.el);
1140
1140
  }
1141
1141
  });
1142
- this.el.addEventListener("phx:show-end", () => this.el.focus());
1143
- if (window.getComputedStyle(this.el).display !== "none") {
1144
- aria_default.focusFirst(this.el);
1142
+ if (!this.el.contains(document.activeElement)) {
1143
+ this.el.addEventListener("phx:show-end", () => this.el.focus());
1144
+ if (window.getComputedStyle(this.el).display !== "none") {
1145
+ aria_default.focusFirst(this.el);
1146
+ }
1145
1147
  }
1146
1148
  }
1147
1149
  }
@@ -1439,7 +1441,7 @@ var DOMPostMorphRestorer = class {
1439
1441
  }
1440
1442
  };
1441
1443
 
1442
- // node_modules/morphdom/dist/morphdom-esm.js
1444
+ // ../node_modules/morphdom/dist/morphdom-esm.js
1443
1445
  var DOCUMENT_FRAGMENT_NODE = 11;
1444
1446
  function morphAttrs(fromNode, toNode) {
1445
1447
  var toNodeAttrs = toNode.attributes;
@@ -2316,7 +2318,7 @@ var DOMPatch = class {
2316
2318
  transitionPendingRemoves() {
2317
2319
  let { pendingRemoves, liveSocket } = this;
2318
2320
  if (pendingRemoves.length > 0) {
2319
- liveSocket.transitionRemoves(pendingRemoves, false, () => {
2321
+ liveSocket.transitionRemoves(pendingRemoves, () => {
2320
2322
  pendingRemoves.forEach((el) => {
2321
2323
  let child = dom_default.firstPhxChild(el);
2322
2324
  if (child) {
@@ -2776,10 +2778,10 @@ var JS = {
2776
2778
  view.liveSocket.pushHistoryPatch(e, href, replace ? "replace" : "push", sourceEl);
2777
2779
  },
2778
2780
  exec_focus(e, eventType, phxEvent, view, sourceEl, el) {
2779
- window.requestAnimationFrame(() => aria_default.attemptFocus(el));
2781
+ aria_default.attemptFocus(el);
2780
2782
  },
2781
2783
  exec_focus_first(e, eventType, phxEvent, view, sourceEl, el) {
2782
- window.requestAnimationFrame(() => aria_default.focusFirstInteractive(el) || aria_default.focusFirst(el));
2784
+ aria_default.focusFirstInteractive(el) || aria_default.focusFirst(el);
2783
2785
  },
2784
2786
  exec_push_focus(e, eventType, phxEvent, view, sourceEl, el) {
2785
2787
  window.requestAnimationFrame(() => focusStack.push(el || sourceEl));
@@ -2885,18 +2887,14 @@ var JS = {
2885
2887
  }
2886
2888
  } else {
2887
2889
  if (this.isVisible(el)) {
2888
- window.requestAnimationFrame(() => {
2889
- el.dispatchEvent(new Event("phx:hide-start"));
2890
- dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = "none");
2891
- el.dispatchEvent(new Event("phx:hide-end"));
2892
- });
2890
+ el.dispatchEvent(new Event("phx:hide-start"));
2891
+ dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = "none");
2892
+ el.dispatchEvent(new Event("phx:hide-end"));
2893
2893
  } else {
2894
- window.requestAnimationFrame(() => {
2895
- el.dispatchEvent(new Event("phx:show-start"));
2896
- let stickyDisplay = display || this.defaultDisplay(el);
2897
- dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
2898
- el.dispatchEvent(new Event("phx:show-end"));
2899
- });
2894
+ el.dispatchEvent(new Event("phx:show-start"));
2895
+ let stickyDisplay = display || this.defaultDisplay(el);
2896
+ dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
2897
+ el.dispatchEvent(new Event("phx:show-end"));
2900
2898
  }
2901
2899
  }
2902
2900
  },
@@ -4740,7 +4738,7 @@ var LiveSocket = class {
4740
4738
  }
4741
4739
  // public
4742
4740
  version() {
4743
- return "1.0.3";
4741
+ return "1.0.4";
4744
4742
  }
4745
4743
  isProfileEnabled() {
4746
4744
  return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
@@ -4957,20 +4955,21 @@ var LiveSocket = class {
4957
4955
  browser_default.redirect(to, flash);
4958
4956
  }
4959
4957
  replaceMain(href, flash, callback = null, linkRef = this.setPendingLink(href)) {
4960
- let liveReferer = this.currentLocation.href;
4958
+ const liveReferer = this.currentLocation.href;
4961
4959
  this.outgoingMainEl = this.outgoingMainEl || this.main.el;
4962
- let removeEls = dom_default.all(this.outgoingMainEl, `[${this.binding("remove")}]`);
4963
- let newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
4960
+ const stickies = dom_default.findPhxSticky(document) || [];
4961
+ const removeEls = dom_default.all(this.outgoingMainEl, `[${this.binding("remove")}]`).filter((el) => !dom_default.isChildOfAny(el, stickies));
4962
+ const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
4964
4963
  this.main.showLoader(this.loaderTimeout);
4965
4964
  this.main.destroy();
4966
4965
  this.main = this.newRootView(newMainEl, flash, liveReferer);
4967
4966
  this.main.setRedirect(href);
4968
- this.transitionRemoves(removeEls, true);
4967
+ this.transitionRemoves(removeEls);
4969
4968
  this.main.join((joinCount, onDone) => {
4970
4969
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
4971
4970
  this.requestDOMUpdate(() => {
4972
4971
  removeEls.forEach((el) => el.remove());
4973
- dom_default.findPhxSticky(document).forEach((el) => newMainEl.appendChild(el));
4972
+ stickies.forEach((el) => newMainEl.appendChild(el));
4974
4973
  this.outgoingMainEl.replaceWith(newMainEl);
4975
4974
  this.outgoingMainEl = null;
4976
4975
  callback && callback(linkRef);
@@ -4979,12 +4978,8 @@ var LiveSocket = class {
4979
4978
  }
4980
4979
  });
4981
4980
  }
4982
- transitionRemoves(elements, skipSticky, callback) {
4981
+ transitionRemoves(elements, callback) {
4983
4982
  let removeAttr = this.binding("remove");
4984
- if (skipSticky) {
4985
- const stickies = dom_default.findPhxSticky(document) || [];
4986
- elements = elements.filter((el) => !dom_default.isChildOfAny(el, stickies));
4987
- }
4988
4983
  let silenceEvents = (e) => {
4989
4984
  e.preventDefault();
4990
4985
  e.stopImmediatePropagation();
@@ -5344,7 +5339,8 @@ var LiveSocket = class {
5344
5339
  this.registerNewLocation(window.location);
5345
5340
  }
5346
5341
  historyRedirect(e, href, linkState, flash, targetEl) {
5347
- if (targetEl && e.isTrusted && e.type !== "popstate") {
5342
+ const clickLoading = targetEl && e.isTrusted && e.type !== "popstate";
5343
+ if (clickLoading) {
5348
5344
  targetEl.classList.add("phx-click-loading");
5349
5345
  }
5350
5346
  if (!this.isConnected() || !this.main.isMain()) {
@@ -5370,6 +5366,9 @@ var LiveSocket = class {
5370
5366
  dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false, direction: "forward" } });
5371
5367
  this.registerNewLocation(window.location);
5372
5368
  }
5369
+ if (clickLoading) {
5370
+ targetEl.classList.remove("phx-click-loading");
5371
+ }
5373
5372
  done();
5374
5373
  });
5375
5374
  });