mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(html-reporter): race condition where form submission used stale filterText state (#36260)
This commit is contained in:
parent
92994a8f85
commit
3cb987f383
@ -60,13 +60,16 @@ export const GlobalFilterView: React.FC<{
|
||||
event => {
|
||||
event.preventDefault();
|
||||
const url = new URL(window.location.href);
|
||||
url.hash = filterText ? '?' + new URLSearchParams({ q: filterText }) : '';
|
||||
// If <form/> onSubmit happens immediately after <input/> onChange, the filterText state is not updated yet.
|
||||
// Using FormData here is a workaround to get the latest value.
|
||||
const q = new FormData(event.target as HTMLFormElement).get('q') as string;
|
||||
url.hash = q ? '?' + new URLSearchParams({ q }) : '';
|
||||
navigate(url);
|
||||
}
|
||||
}>
|
||||
{icons.search()}
|
||||
{/* Use navigationId to reset defaultValue */}
|
||||
<input spellCheck={false} className='form-control subnav-search-input input-contrast width-full' value={filterText} onChange={e => {
|
||||
<input name='q' spellCheck={false} className='form-control subnav-search-input input-contrast width-full' value={filterText} onChange={e => {
|
||||
setFilterText(e.target.value);
|
||||
}}></input>
|
||||
</form>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user