Skip to content

Commit

Permalink
exportCSV - render download link to OverlayContainer rather than docu…
Browse files Browse the repository at this point in the history
…ment.body (#91)
  • Loading branch information
JohnC-80 authored Dec 3, 2024
1 parent a08924f commit bd31a5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change history for stripes-util

## 6.3.0 IN PROGRESS
* `exportCSV` render download link to `OverlayContainer` to allow click to work and avoid focus-trapping of stripes modals. Refs STUTL-48.

## [6.2.0](https://github.com/folio-org/stripes-util/tree/v6.2.0) (2024-10-11)
[Full Changelog](https://github.com/folio-org/stripes-util/compare/v6.1.0...v6.2.0)
Expand Down
7 changes: 5 additions & 2 deletions lib/exportCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ function triggerDownload(csv, fileTitle) {
link.setAttribute('href', url);
link.setAttribute('download', exportedFilename);
link.style.visibility = 'hidden';
document.body.appendChild(link);
const linkContainer = document.getElementById('OverlayContainer') || document.body;
linkContainer.appendChild(link);
window.setTimeout(() => {
const currentFocused = document.activeElement;
link.click();
document.body.removeChild(link);
currentFocused.focus();
linkContainer.removeChild(link);
}, 50); // Need to debounce this click event from others (Pane actionMenuItems dropdown)
} else {
console.error('Failed to trigger download for CSV data'); // eslint-disable-line no-console
Expand Down

0 comments on commit bd31a5b

Please sign in to comment.