@descope/web-components-ui 3.14.10 → 3.15.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.
package/dist/index.esm.js CHANGED
@@ -15686,6 +15686,10 @@ const customMixin$8 = (superclass) =>
15686
15686
  return this.getAttribute('opened') === 'true';
15687
15687
  }
15688
15688
 
15689
+ get closeOnOutsideClick() {
15690
+ return this.getAttribute('close-on-outside-click') === 'true';
15691
+ }
15692
+
15689
15693
  handleOpened() {
15690
15694
  if (this.opened) {
15691
15695
  this.style.display = '';
@@ -15751,6 +15755,28 @@ const customMixin$8 = (superclass) =>
15751
15755
  overlay._enterModalState = () => {};
15752
15756
 
15753
15757
  overlay.close = () => false;
15758
+
15759
+ // close the modal when the user clicks/taps the backdrop (outside the modal
15760
+ // box). Vaadin's own outside-click does not fire here because we keep the
15761
+ // overlay in the shadow DOM (see _attachOverlay above), which leaves it out
15762
+ // of Vaadin's overlay stack, so we detect the backdrop click ourselves.
15763
+ // the listener is always attached and reads `closeOnOutsideClick` at click
15764
+ // time, so toggling the attribute after init is respected.
15765
+ overlay.addEventListener('click', (event) => {
15766
+ if (!this.closeOnOutsideClick || !this.opened) return;
15767
+
15768
+ // the visible modal box; clicks inside it (content + its padding) keep
15769
+ // the modal open, only clicks on the dimmed backdrop close it. if we
15770
+ // can't find the box, don't close - safer than closing on an inside click
15771
+ const overlayPart = overlay.shadowRoot?.querySelector('[part="overlay"]');
15772
+ if (!overlayPart || event.composedPath().includes(overlayPart)) {
15773
+ return;
15774
+ }
15775
+
15776
+ // just close ourselves; consumers that need to react (e.g. ModalDriver
15777
+ // resetting the content) observe the `opened` attribute
15778
+ this.removeAttribute('opened');
15779
+ });
15754
15780
  }
15755
15781
  };
15756
15782