glitchgrab 1.31.0 → 1.32.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.mjs CHANGED
@@ -935,6 +935,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
935
935
  return /* @__PURE__ */ jsxs(
936
936
  "div",
937
937
  {
938
+ "data-glitchgrab-layer": "",
938
939
  style: {
939
940
  position: "fixed",
940
941
  inset: 0,
@@ -1511,13 +1512,29 @@ function ReportDialog({
1511
1512
  const isPushToTalkRef = useRef2(false);
1512
1513
  useEffect2(() => {
1513
1514
  if (!isOpen) return;
1514
- const dialogs = Array.from(
1515
- document.querySelectorAll(
1516
- '[role="dialog"][data-state="open"]'
1517
- )
1518
- );
1519
- dialogs.forEach((d) => d.setAttribute("inert", ""));
1520
- return () => dialogs.forEach((d) => d.removeAttribute("inert"));
1515
+ const HOST_LAYERS = '[role="dialog"],[role="alertdialog"],[role="menu"],[role="listbox"]';
1516
+ const inerted = /* @__PURE__ */ new Set();
1517
+ const applyInert = () => {
1518
+ document.querySelectorAll(HOST_LAYERS).forEach((el) => {
1519
+ if (el.closest("[data-glitchgrab-layer]")) return;
1520
+ if (el.querySelector("[data-glitchgrab-layer]")) return;
1521
+ if (inerted.has(el) || el.hasAttribute("inert")) return;
1522
+ el.setAttribute("inert", "");
1523
+ inerted.add(el);
1524
+ });
1525
+ };
1526
+ applyInert();
1527
+ const observer = new MutationObserver((mutations) => {
1528
+ const structural = mutations.some(
1529
+ (m) => m.addedNodes.length > 0 || m.removedNodes.length > 0
1530
+ );
1531
+ if (structural) applyInert();
1532
+ });
1533
+ observer.observe(document.body, { childList: true, subtree: true });
1534
+ return () => {
1535
+ observer.disconnect();
1536
+ inerted.forEach((el) => el.removeAttribute("inert"));
1537
+ };
1521
1538
  }, [isOpen]);
1522
1539
  const [step, setStep] = useState2(1);
1523
1540
  const [reportType, setReportType] = useState2("BUG");
@@ -1608,6 +1625,8 @@ function ReportDialog({
1608
1625
  };
1609
1626
  const handleOpen = async () => {
1610
1627
  setSubmitted(false);
1628
+ closePreview();
1629
+ setAnnotatingIndex(null);
1611
1630
  if (availableTypes.length === 1) {
1612
1631
  setReportType(availableTypes[0]);
1613
1632
  setStep(2);
@@ -1634,14 +1653,15 @@ function ReportDialog({
1634
1653
  if (!isOpen) return;
1635
1654
  const handleEsc = (e) => {
1636
1655
  if (e.key === "Escape") {
1637
- if (previewZoomed) setPreviewZoomed(false);
1656
+ if (annotatingIndex !== null) setAnnotatingIndex(null);
1657
+ else if (previewZoomed) setPreviewZoomed(false);
1638
1658
  else if (previewIndex !== null) closePreview();
1639
1659
  else handleClose();
1640
1660
  }
1641
1661
  };
1642
1662
  document.addEventListener("keydown", handleEsc);
1643
1663
  return () => document.removeEventListener("keydown", handleEsc);
1644
- }, [isOpen, previewIndex, previewZoomed]);
1664
+ }, [isOpen, previewIndex, previewZoomed, annotatingIndex]);
1645
1665
  useEffect2(() => {
1646
1666
  if (previewIndex === null || annotatingIndex !== null) return;
1647
1667
  const handlePointerDown = (e) => {
@@ -1776,6 +1796,8 @@ function ReportDialog({
1776
1796
  const handleClose = () => {
1777
1797
  stopVoice();
1778
1798
  setIsOpen(false);
1799
+ closePreview();
1800
+ setAnnotatingIndex(null);
1779
1801
  setStep(1);
1780
1802
  setRating(0);
1781
1803
  setHoveredStar(0);
@@ -2026,6 +2048,7 @@ function ReportDialog({
2026
2048
  /* @__PURE__ */ jsx2(
2027
2049
  "div",
2028
2050
  {
2051
+ "data-glitchgrab-layer": "",
2029
2052
  style: {
2030
2053
  position: "fixed",
2031
2054
  inset: 0,
@@ -3451,10 +3474,11 @@ function ReportDialog({
3451
3474
  style: { display: "none" }
3452
3475
  }
3453
3476
  ),
3454
- previewIndex !== null && screenshots[previewIndex] && createPortal(
3477
+ isOpen && previewIndex !== null && screenshots[previewIndex] && createPortal(
3455
3478
  /* @__PURE__ */ jsxs2(
3456
3479
  "div",
3457
3480
  {
3481
+ "data-glitchgrab-layer": "",
3458
3482
  style: {
3459
3483
  position: "fixed",
3460
3484
  inset: 0,
@@ -3607,7 +3631,7 @@ function ReportDialog({
3607
3631
  ),
3608
3632
  document.body
3609
3633
  ),
3610
- annotatingIndex !== null && screenshots[annotatingIndex] && createPortal(
3634
+ isOpen && annotatingIndex !== null && screenshots[annotatingIndex] && createPortal(
3611
3635
  /* @__PURE__ */ jsx2(
3612
3636
  AnnotationCanvas,
3613
3637
  {