drab 7.0.0 → 7.0.1

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.
@@ -32,6 +32,9 @@ export class Dialog extends Lifecycle(Trigger(Content())) {
32
32
  get #clickOutsideClose() {
33
33
  return this.hasAttribute("click-outside-close");
34
34
  }
35
+ get #scrollbarWidth() {
36
+ return window.innerWidth - document.documentElement.clientWidth;
37
+ }
35
38
  /** Remove scroll from the body when open with the `remove-body-scroll` attribute. */
36
39
  #toggleBodyScroll(show) {
37
40
  if (this.#removeBodyScroll) {
@@ -68,10 +71,10 @@ export class Dialog extends Lifecycle(Trigger(Content())) {
68
71
  // https://blog.webdevsimplified.com/2023-04/html-dialog/#close-on-outside-click
69
72
  this.#dialog.addEventListener("click", (e) => {
70
73
  let rect = this.#dialog.getBoundingClientRect();
71
- // If dialog covers full viewport (with a small tolerance), use first child element for hit testing
74
+ // If dialog covers full viewport, use first child element for hit testing
72
75
  // Example: https://picocss.com/docs/modal
73
- if (rect.width - window.innerWidth <= 5 && // 5px tolerance for rounding issues
74
- rect.height - window.innerHeight <= 5 &&
76
+ if (Math.abs(rect.width - window.innerWidth) <= this.#scrollbarWidth && // 5px tolerance for rounding issues
77
+ Math.abs(rect.height - window.innerHeight) <= 0 &&
75
78
  this.#dialog.firstElementChild) {
76
79
  rect = this.#dialog.firstElementChild.getBoundingClientRect();
77
80
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "drab",
3
3
  "description": "Interactivity for You",
4
- "version": "7.0.0",
4
+ "version": "7.0.1",
5
5
  "homepage": "https://drab.robino.dev",
6
6
  "license": "MIT",
7
7
  "author": {