Skip to content

Commit

Permalink
Fix collapsed packages when navigate to vulnerability page (#2198)
Browse files Browse the repository at this point in the history
Issue: #381

Initially the page listens the window onload event, and programatically
clicks on the headers so the sections will be expanded. But since we use
Turbo, it will request the new page by using fetch request rather than
doing a full reload, so the `load` event won't be triggered.

In this PR we make the script listens `turbo:load` event which always
happens when visiting a new page.

Result:
![May-09-2024
16-34-20](https://github.com/google/osv.dev/assets/13760813/2de992f2-9b28-426b-8dda-6885bddc13ef)
  • Loading branch information
ZhangChen199102 committed May 14, 2024
1 parent fb7591b commit fc144b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcp/appengine/frontend3/src/templates/vulnerability.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ <h3 class="mdc-layout-grid__cell--span-3">
the page is loaded. So we decide to programmatically click on header of collapsed
packages after the page is loaded, and the content will be visible.
*/
window.addEventListener('load', function() {
const package_headers = document.querySelectorAll('.package-header[affordance="collapse"]')
document.addEventListener('turbo:load', function() {
const package_headers = document.querySelectorAll('.package-header[affordance="collapse"][aria-expanded="false"]')
package_headers.forEach((header) => {
header.click()
});
Expand Down

0 comments on commit fc144b7

Please sign in to comment.