File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
packages/html-reporter/src Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,16 @@ export const GlobalFilterView: React.FC<{
60
60
event => {
61
61
event . preventDefault ( ) ;
62
62
const url = new URL ( window . location . href ) ;
63
- url . hash = filterText ? '?' + new URLSearchParams ( { q : filterText } ) : '' ;
63
+ // If <form/> onSubmit happens immediately after <input/> onChange, the filterText state is not updated yet.
64
+ // Using FormData here is a workaround to get the latest value.
65
+ const q = new FormData ( event . target as HTMLFormElement ) . get ( 'q' ) as string ;
66
+ url . hash = q ? '?' + new URLSearchParams ( { q } ) : '' ;
64
67
navigate ( url ) ;
65
68
}
66
69
} >
67
70
{ icons . search ( ) }
68
71
{ /* Use navigationId to reset defaultValue */ }
69
- < input spellCheck = { false } className = 'form-control subnav-search-input input-contrast width-full' value = { filterText } onChange = { e => {
72
+ < input name = 'q' spellCheck = { false } className = 'form-control subnav-search-input input-contrast width-full' value = { filterText } onChange = { e => {
70
73
setFilterText ( e . target . value ) ;
71
74
} } > </ input >
72
75
</ form >
You can’t perform that action at this time.
0 commit comments