analytica-frontend-lib 1.1.87 → 1.1.89

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.
@@ -217,14 +217,34 @@ var Modal = ({
217
217
  return () => document.removeEventListener("keydown", handleEscape);
218
218
  }, [isOpen, closeOnEscape, onClose]);
219
219
  useEffect(() => {
220
+ if (!isOpen) return;
221
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
220
222
  const originalOverflow = document.body.style.overflow;
221
- if (isOpen) {
222
- document.body.style.overflow = "hidden";
223
- } else {
224
- document.body.style.overflow = originalOverflow;
223
+ const originalPaddingRight = document.body.style.paddingRight;
224
+ document.body.style.overflow = "hidden";
225
+ if (scrollbarWidth > 0) {
226
+ document.body.style.paddingRight = `${scrollbarWidth}px`;
227
+ const overlay = document.createElement("div");
228
+ overlay.id = "modal-scrollbar-overlay";
229
+ overlay.style.cssText = `
230
+ position: fixed;
231
+ top: 0;
232
+ right: 0;
233
+ width: ${scrollbarWidth}px;
234
+ height: 100vh;
235
+ background-color: rgb(0 0 0 / 0.6);
236
+ z-index: 40;
237
+ pointer-events: none;
238
+ `;
239
+ document.body.appendChild(overlay);
225
240
  }
226
241
  return () => {
227
242
  document.body.style.overflow = originalOverflow;
243
+ document.body.style.paddingRight = originalPaddingRight;
244
+ const overlay = document.getElementById("modal-scrollbar-overlay");
245
+ if (overlay) {
246
+ overlay.remove();
247
+ }
228
248
  };
229
249
  }, [isOpen]);
230
250
  if (!isOpen) return null;