-
-
Notifications
You must be signed in to change notification settings - Fork 456
Closed
Labels
Description
Describe the bug
The filter on the coverage resets its state when I go to the previous page.
To Reproduce
Python 3.8.10
coverage.py v7.0.1 in my code, and the live example as linked below in the v7.4.0
- Go to the example page, as indicated here:
- See the number of lines, 10 lines (counting the "total").
- Type something in the filter on the top right end of the page, e.g.,
utils
. The results will be filtered and there are now only 4 lines (counting the "total"). - Click in a file, e.g.,
cogapp/utils.py
- Go back to the previous page (click ALT + left)
- See that the text is still on the filter, on the top right of the page, but the results is not filtered.
Expected behavior
When I go back to the previous page, the results must be filtered.
Additional context
When the code below runs, the filter text is still empty.
// Trigger change event on setup, to force filter on page refresh
// (filter value may still be present).
document.getElementById("filter").dispatchEvent(new Event("input"));
Hotfix
Whithout thinking too much, this is a solution that I came up with: appending a new keyboard event after a timeout period. It's not the ideal, but it's working.
This is my script to see the coverage results:
coverage html && \
echo 'window.addEventListener("load",(function(){setTimeout((function(){const t=document.getElementById("filter");t&&t.dispatchEvent(new Event("input"))}),5)}));' >> htmlcov/coverage_html.js && \
xdg-open 'http://localhost:8000' && \
python -m http.server -d htmlcov