• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

react-ui-org / react-ui / 12744940249

13 Jan 2025 10:09AM UTC coverage: 80.471% (-11.5%) from 91.979%
12744940249

Pull #544

github

web-flow
Merge ec8d690d5 into 684d5abff
Pull Request #544: Re-implement `Modal` component using HTMLDialogElement (#461)

743 of 923 branches covered (80.5%)

Branch coverage included in aggregate %.

4 of 43 new or added lines in 7 files covered. (9.3%)

65 existing lines in 5 files now uncovered.

658 of 818 relevant lines covered (80.44%)

61.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.7
/src/components/Modal/_hooks/useModalScrollPrevention.js
1
import { useLayoutEffect } from 'react';
2

3
export const useModalScrollPrevention = (preventScrollUnderneath) => {
4✔
UNCOV
4
  useLayoutEffect(
×
5
    () => {
UNCOV
6
      if (preventScrollUnderneath === 'off') {
×
UNCOV
7
        return () => {};
×
8
      }
9

UNCOV
10
      if (preventScrollUnderneath instanceof HTMLElement) {
×
UNCOV
11
        const scrollableElement = preventScrollUnderneath;
×
12

UNCOV
13
        const scrollbarWidth = Math.abs(window.innerWidth - window.document.documentElement.clientWidth);
×
UNCOV
14
        const prevOverflow = scrollableElement.style.overflow;
×
UNCOV
15
        const prevPaddingRight = scrollableElement.style.paddingRight;
×
16

UNCOV
17
        scrollableElement.style.overflow = 'hidden';
×
18

UNCOV
19
        if (Number.isNaN(parseInt(prevPaddingRight, 10))) {
×
UNCOV
20
          scrollableElement.style.paddingRight = `${scrollbarWidth}px`;
×
21
        } else {
UNCOV
22
          scrollableElement.style.paddingRight = `calc(${prevPaddingRight} + ${scrollbarWidth}px)`;
×
23
        }
24

UNCOV
25
        return () => {
×
UNCOV
26
          scrollableElement.style.overflow = prevOverflow;
×
UNCOV
27
          scrollableElement.style.paddingRight = prevPaddingRight;
×
28
        };
29
      }
30

UNCOV
31
      preventScrollUnderneath?.start();
×
32

UNCOV
33
      return preventScrollUnderneath?.reset;
×
34
    },
35
    [preventScrollUnderneath],
36
  );
37
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc