Skip to content

Commit 1831a41

Browse files
clear filter when clicking twitch app home icon
1 parent 146dc1f commit 1831a41

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/components/UI/navigation/HomeIcon.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useContext } from 'react'
22
import logo from './../../../images/fallback.png'
33
import { ContextScreenWidth } from '../../../App'
4+
import { setItemInStorage } from '../../../helper/setItemInStorage'
45

56
export const HomeIcon = () => {
67
const contextScreenWidth = useContext(ContextScreenWidth)
@@ -10,18 +11,24 @@ export const HomeIcon = () => {
1011
)
1112
}
1213

14+
const clearFilter = () => {
15+
setItemInStorage('filter', '')
16+
}
17+
1318
const handleKeyDown = (e: React.KeyboardEvent<HTMLAnchorElement>) => {
1419
if (e.key === ' ') {
1520
const target = e.target as HTMLElement
1621
target.click()
1722
e.preventDefault()
23+
clearFilter()
1824
}
1925
}
2026

2127
return (
2228
<a
2329
href="/twitch-app/"
2430
className="flex flex-row px-2 rounded-md pseudo-zinc navigation"
31+
onClick={clearFilter}
2532
onKeyDown={handleKeyDown}
2633
title="Homepage"
2734
data-testid="navigation-homepage-anchor"

0 commit comments

Comments
 (0)