File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,14 @@ import { Button } from "../../../ui/atoms/button";
4
4
5
5
import "./filter.scss" ;
6
6
import { useGleanClick } from "../../../telemetry/glean-context" ;
7
- import { SIDEBAR_FILTER_FOCUS } from "../../../telemetry/constants" ;
7
+ import {
8
+ SIDEBAR_FILTER_FOCUS ,
9
+ SIDEBAR_FILTER_TYPED ,
10
+ } from "../../../telemetry/constants" ;
8
11
9
12
export function SidebarFilter ( ) {
10
13
const [ isActive , setActive ] = useState < Boolean > ( false ) ;
14
+ const [ hasTyped , setTyped ] = useState < Boolean > ( false ) ;
11
15
const { query, setQuery, matchCount } = useSidebarFilter ( ) ;
12
16
const gleanClick = useGleanClick ( ) ;
13
17
@@ -17,6 +21,24 @@ export function SidebarFilter() {
17
21
}
18
22
} , [ gleanClick , isActive ] ) ;
19
23
24
+ useEffect ( ( ) => {
25
+ if ( query ) {
26
+ setTyped ( true ) ;
27
+ }
28
+ } , [ query , setTyped ] ) ;
29
+
30
+ useEffect ( ( ) => {
31
+ if ( hasTyped ) {
32
+ gleanClick ( SIDEBAR_FILTER_TYPED ) ;
33
+ }
34
+ } , [ gleanClick , hasTyped ] ) ;
35
+
36
+ useEffect ( ( ) => {
37
+ if ( ! isActive ) {
38
+ setTyped ( false ) ;
39
+ }
40
+ } , [ isActive , setTyped ] ) ;
41
+
20
42
return (
21
43
< section className = "sidebar-filter-container" >
22
44
< div className = { `sidebar-filter ${ query ? "has-input" : "" } ` } >
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export const OFFER_OVERVIEW_CLICK = "offer_overview_click";
4
4
export const SIDEBAR_CLICK = "sidebar_click" ;
5
5
export const SIDEBAR_CLICK_WITH_FILTER = "sidebar_click_with_filter" ;
6
6
export const SIDEBAR_FILTER_FOCUS = "sidebar_filter_focus" ;
7
+ export const SIDEBAR_FILTER_TYPED = "sidebar_filter_typed" ;
7
8
export const TOC_CLICK = "toc_click" ;
8
9
/** Replaced "top_nav_already_subscriber" in July 2023. */
9
10
export const TOP_NAV_LOGIN = "top_nav: login" ;
You can’t perform that action at this time.
0 commit comments