Skip to content

Commit 5dda876

Browse files
committed
Remove react-scrollbar-size
1 parent c9f0985 commit 5dda876

File tree

7 files changed

+57
-23
lines changed

7 files changed

+57
-23
lines changed

.github/workflows/push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
# the paths-ignore in both push and pull_request events.
99
# More info: https://github.com/actions/runner/issues/1182
1010
paths-ignore:
11+
- ".github/prompts/**"
1112
- ".husky/**"
1213
- ".vscode/**"
1314
- "website/**"
@@ -19,6 +20,7 @@ on:
1920
branches:
2021
- "main"
2122
paths-ignore:
23+
- ".github/prompts/**"
2224
- ".husky/**"
2325
- ".vscode/**"
2426
- "website/**"

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
"react-product-fruits": "^2.2.61",
142142
"react-redux": "^9.2.0",
143143
"react-router": "^7.5.2",
144-
"react-scrollbar-size": "^5.0.0",
145144
"react-syntax-highlighter": "^15.6.1",
146145
"react-transition-group": "^4.4.5",
147146
"recharts": "^2.15.3",

src/components/RecentActivity/LiveView/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { format } from "date-fns";
22
import type { MouseEvent, UIEvent } from "react";
33
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
44
import useDimensions from "react-cool-dimensions";
5-
import useScrollbarSize from "react-scrollbar-size";
6-
75
import {
86
Area,
97
CartesianGrid,
@@ -18,6 +16,7 @@ import {
1816
import type { DefaultTheme } from "styled-components";
1917
import { useTheme } from "styled-components";
2018
import { usePrevious } from "../../../hooks/usePrevious";
19+
import { useScrollbarDimensions } from "../../../hooks/useScrollbarDimensions";
2120
import { isNumber } from "../../../typeGuards/isNumber";
2221
import { sendUserActionTrackingEvent } from "../../../utils/actions/sendUserActionTrackingEvent";
2322
import { convertToDurationUnit } from "../../../utils/convertToDurationUnit";
@@ -160,7 +159,7 @@ export const LiveView = ({ data, onClose }: LiveViewProps) => {
160159
const [areaTooltip, setAreaTooltip] = useState<Coordinates>();
161160
const [dotToolTip, setDotTooltip] = useState<DotTooltipProps>();
162161
const [scrollPercentagePosition, setScrollPercentagePosition] = useState(1);
163-
const scrollbar = useScrollbarSize();
162+
const scrollbar = useScrollbarDimensions();
164163
const [areErrorsVisible, setAreErrorsVisible] = useState(true);
165164

166165
useEffect(() => {
@@ -357,7 +356,7 @@ export const LiveView = ({ data, onClose }: LiveViewProps) => {
357356
chartContainerRef.current &&
358357
chartContainerRef.current.scrollWidth >
359358
chartContainerRef.current.clientWidth
360-
? scrollbar.width
359+
? scrollbar.height
361360
: 0;
362361

363362
const changedPercentile = useMemo(() => {

src/components/common/IssuesReport/Chart/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { UIEvent } from "react";
22
import { useEffect, useState } from "react";
33
import useDimensions from "react-cool-dimensions";
4-
import useScrollbarSize from "react-scrollbar-size";
54
import type { Input } from "squarify";
5+
import { useScrollbarDimensions } from "../../../../hooks/useScrollbarDimensions";
66
import { sendUserActionTrackingEvent } from "../../../../utils/actions/sendUserActionTrackingEvent";
77
import { TreeMap } from "../../TreeMap";
88
import type { TileData } from "../../TreeMap/types";
@@ -23,7 +23,7 @@ export const Chart = ({
2323
const { width, height, entry, observe } = useDimensions();
2424
const [isLeftOverlayVisible, setIsLeftOverlayVisible] = useState(false);
2525
const [isRightOverlayVisible, setIsRightOverlayVisible] = useState(false);
26-
const scrollbar = useScrollbarSize();
26+
const scrollbar = useScrollbarDimensions();
2727

2828
useEffect(() => {
2929
if (entry) {
@@ -105,12 +105,12 @@ export const Chart = ({
105105
<s.Overlay
106106
$visible={isLeftOverlayVisible}
107107
$placement={"left"}
108-
style={{ bottom: scrollbar.width }}
108+
style={{ bottom: scrollbar.height }}
109109
/>
110110
<s.Overlay
111111
$visible={isRightOverlayVisible}
112112
$placement={"right"}
113-
style={{ bottom: scrollbar.width }}
113+
style={{ bottom: scrollbar.height }}
114114
/>
115115
</s.Container>
116116
);

src/components/common/JiraTicket/Field/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useCallback, useRef } from "react";
22
import useDimensions from "react-cool-dimensions";
3-
import useScrollbarSize from "react-scrollbar-size";
3+
import { useScrollbarDimensions } from "../../../../hooks/useScrollbarDimensions";
44
import * as s from "./styles";
55
import type { ButtonPosition, FieldProps } from "./types";
66

77
export const Field = ({ multiline, children, button }: FieldProps) => {
8-
const scrollbar = useScrollbarSize();
8+
const scrollbar = useScrollbarDimensions();
99
const contentRef = useRef<HTMLDivElement | null>(null);
1010
const { observe } = useDimensions();
1111

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useEffect, useState } from "react";
2+
3+
interface ScrollbarDimensions {
4+
width: number;
5+
height: number;
6+
}
7+
8+
export const useScrollbarDimensions = () => {
9+
const [dimensions, setDimensions] = useState<ScrollbarDimensions>({
10+
width: 0,
11+
height: 0
12+
});
13+
14+
useEffect(() => {
15+
const calculateDimensions = (): ScrollbarDimensions => {
16+
const verticalContainer = document.createElement("div");
17+
verticalContainer.style.visibility = "hidden";
18+
verticalContainer.style.overflow = "scroll";
19+
verticalContainer.style.width = "100px";
20+
verticalContainer.style.height = "100px";
21+
document.body.appendChild(verticalContainer);
22+
23+
const horizontalContainer = document.createElement("div");
24+
horizontalContainer.style.visibility = "hidden";
25+
horizontalContainer.style.overflowX = "scroll";
26+
horizontalContainer.style.overflowY = "hidden";
27+
horizontalContainer.style.width = "100px";
28+
horizontalContainer.style.height = "100px";
29+
document.body.appendChild(horizontalContainer);
30+
31+
const width =
32+
verticalContainer.offsetWidth - verticalContainer.clientWidth;
33+
const height =
34+
horizontalContainer.offsetHeight - horizontalContainer.clientHeight;
35+
36+
document.body.removeChild(verticalContainer);
37+
document.body.removeChild(horizontalContainer);
38+
39+
return { width, height };
40+
};
41+
42+
setDimensions(calculateDimensions());
43+
}, []);
44+
45+
return dimensions;
46+
};

0 commit comments

Comments
 (0)