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

JedWatson / react-select / 9de42ca4-8c55-4031-8310-e7e0a2b0128b

26 Oct 2024 11:27AM CUT coverage: 75.844%. Remained the same
9de42ca4-8c55-4031-8310-e7e0a2b0128b

Pull #5880

circleci

lukebennett88
add box-sizing to border-box for RequiredInput

adding `required` would otherwise cause an extra (unstylable) component to be added which has some implicit padding from the user agent style sheet (inputs have padding) which could cause horizontal scrolling when the whole scroll field is 100% wide.
Pull Request #5880: add box-sizing to border-box for RequiredInput

658 of 1052 branches covered (62.55%)

1033 of 1362 relevant lines covered (75.84%)

1934.69 hits per line

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

77.78
/packages/react-select/src/internal/ScrollManager.tsx
1
/** @jsx jsx */
2
import { jsx } from '@emotion/react';
3
import { Fragment, ReactElement, RefCallback, MouseEvent } from 'react';
4
import useScrollCapture from './useScrollCapture';
5
import useScrollLock from './useScrollLock';
6

7
interface Props {
8
  readonly children: (ref: RefCallback<HTMLElement>) => ReactElement;
9
  readonly lockEnabled: boolean;
10
  readonly captureEnabled: boolean;
11
  readonly onBottomArrive?: (event: WheelEvent | TouchEvent) => void;
12
  readonly onBottomLeave?: (event: WheelEvent | TouchEvent) => void;
13
  readonly onTopArrive?: (event: WheelEvent | TouchEvent) => void;
14
  readonly onTopLeave?: (event: WheelEvent | TouchEvent) => void;
15
}
16

17
const blurSelectInput = (event: MouseEvent<HTMLDivElement>) => {
5✔
18
  const element = event.target as HTMLDivElement;
×
19
  return (
×
20
    element.ownerDocument.activeElement &&
×
21
    (element.ownerDocument.activeElement as HTMLElement).blur()
22
  );
23
};
24

25
export default function ScrollManager({
26
  children,
27
  lockEnabled,
28
  captureEnabled = true,
×
29
  onBottomArrive,
30
  onBottomLeave,
31
  onTopArrive,
32
  onTopLeave,
33
}: Props) {
34
  const setScrollCaptureTarget = useScrollCapture({
768✔
35
    isEnabled: captureEnabled,
36
    onBottomArrive,
37
    onBottomLeave,
38
    onTopArrive,
39
    onTopLeave,
40
  });
41
  const setScrollLockTarget = useScrollLock({ isEnabled: lockEnabled });
768✔
42

43
  const targetRef: RefCallback<HTMLElement> = (element) => {
768✔
44
    setScrollCaptureTarget(element);
1,536✔
45
    setScrollLockTarget(element);
1,536✔
46
  };
47

48
  return (
768✔
49
    <Fragment>
50
      {lockEnabled && (
768!
51
        <div
52
          onClick={blurSelectInput}
53
          css={{ position: 'fixed', left: 0, bottom: 0, right: 0, top: 0 }}
54
        />
55
      )}
56
      {children(targetRef)}
57
    </Fragment>
58
  );
59
}
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

© 2025 Coveralls, Inc