Skip to content

Commit bee50a7

Browse files
committed
update:coderabbit_suggestions
1 parent 313cb61 commit bee50a7

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

frontend/__tests__/unit/components/ScrollToTop.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ScrollToTop from 'components/ScrollToTop'
33

44
describe('ScrollToTop component test', () => {
55
beforeEach(() => {
6-
window.scrollTo = jest.fn()
6+
globalThis.scrollTo = jest.fn()
77
Object.defineProperty(globalThis, 'scrollY', { value: 0, writable: true })
88
Object.defineProperty(globalThis, 'innerHeight', { value: 1000, writable: true })
99
})
@@ -45,6 +45,6 @@ describe('ScrollToTop component test', () => {
4545
})
4646

4747
fireEvent.click(button)
48-
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' })
48+
expect(globalThis.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' })
4949
})
5050
})

frontend/src/app/my/mentorship/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const MyMentorshipPage: React.FC = () => {
118118
currentPage={page}
119119
onPageChange={(p) => {
120120
setPage(p)
121-
window.scrollTo({ top: 0, behavior: 'smooth' })
121+
globalThis.scrollTo({ top: 0, behavior: 'smooth' })
122122
}}
123123
onSearch={(q) => {
124124
setSearchQuery(q)

frontend/src/components/Header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Header({ isGitHubAuthEnabled }: { readonly isGitHubAuthE
2626

2727
useEffect(() => {
2828
const handleResize = () => {
29-
if (window.innerWidth >= desktopViewMinWidth) {
29+
if (globalThis.innerWidth >= desktopViewMinWidth) {
3030
setMobileMenuOpen(false)
3131
}
3232
}
@@ -45,11 +45,11 @@ export default function Header({ isGitHubAuthEnabled }: { readonly isGitHubAuthE
4545
}
4646
}
4747

48-
window.addEventListener('resize', handleResize)
48+
globalThis.addEventListener('resize', handleResize)
4949
globalThis.addEventListener('click', handleOutsideClick)
5050

5151
return () => {
52-
window.removeEventListener('resize', handleResize)
52+
globalThis.removeEventListener('resize', handleResize)
5353
globalThis.removeEventListener('click', handleOutsideClick)
5454
}
5555
}, [mobileMenuOpen])

frontend/src/components/MultiSearch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const MultiSearchBar: React.FC<MultiSearchBarProps> = ({
100100
router.push(`/chapters/${suggestion.key}`)
101101
break
102102
case 'events':
103-
window.open((suggestion as Event).url, '_blank')
103+
globalThis.open((suggestion as Event).url, '_blank')
104104
break
105105
case 'organizations':
106106
// Use type guard to safely access login property

frontend/src/components/SingleModuleCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const SingleModuleCard: React.FC<SingleModuleCardProps> = ({
4747

4848
const handleCreate = () => {
4949
setDropdownOpen(false)
50-
router.push(`${window.location.pathname}/modules/create`)
50+
router.push(`${globalThis.location.pathname}/modules/create`)
5151
}
5252

5353
const moduleDetails = [

frontend/src/utils/helpers/githubHeatmap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function getPixelRatio() {
171171
if (typeof globalThis === 'undefined') {
172172
return 1
173173
}
174-
return window.devicePixelRatio || 1
174+
return globalThis.devicePixelRatio || 1
175175
}
176176

177177
const DATE_FORMAT = 'yyyy-MM-dd'

frontend/src/utils/scrollToAnchor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function scrollToAnchor(targetId: string, additionalOffset = 80): void {
1010
const yOffset = -headingHeight - additionalOffset
1111

1212
// Use modern window.scrollY instead of deprecated pageYOffset
13-
const y = element.getBoundingClientRect().top + window.scrollY + yOffset
14-
window.scrollTo({
13+
const y = element.getBoundingClientRect().top + globalThis.scrollY + yOffset
14+
globalThis.scrollTo({
1515
top: y,
1616
behavior: 'smooth',
1717
})

0 commit comments

Comments
 (0)