Skip to content

Commit

Permalink
Fix regression with select inputs (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHerbst authored Oct 17, 2024
1 parent 53b825a commit c7784f5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/handlePrintWindowOnLoad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ export function handlePrintWindowOnLoad(
}
}

// Copy select states. Without this, the first select option is printed, regardless of
// selection state
const selectSelector = 'select';
const originalSelects = (contentNode as Element).querySelectorAll(selectSelector);
const copiedSelects = domDoc.querySelectorAll(selectSelector);
for (let i = 0; i < originalSelects.length; i++) {
copiedSelects[i].value = originalSelects[i].value;
}

if (!ignoreGlobalStyles) {
const styleAndLinkNodes = document.querySelectorAll("style, link[rel~='stylesheet'], link[as='style']");

Expand Down

0 comments on commit c7784f5

Please sign in to comment.