Problem/Motivation
When a Views Data Export display uses automatic download and redirects back to a View with AJAX-enabled exposed filters, the exported file can download again when another AJAX action runs, such as Reset or Apply.
No new export request or batch is started. The previous automatic-download link is triggered again.
Steps to reproduce
- Create a View with exposed filters and Use AJAX enabled.
- Attach a Data Export display using Batch, Automatic download enabled, and redirect to the current display.
- Apply a filter and export the data. The file downloads once as expected.
- Click Reset or Apply on the exposed filters.
- The same exported file downloads again.
Root cause
After the export completes, VDE adds a status message containing:
<a id="vde-automatic-download" data-download-enabled="true" ...>here</a>
Drupal also passes the message through Drupal.announce(), which recreates the message markup inside #drupal-live-announce for screen-reader announcements.
This creates a second #vde-automatic-download element inside the live region.
VDE currently matches #vde-automatic-download anywhere in the document, so when Drupal.attachBehaviors() runs again after any AJAX request, that announcement copy is treated as a real download trigger and executes:
window.location.href = link.href;
This causes the previous export to download again.
The problem is not specific to Reset. Reset simply triggers another AJAX behavior pass; the actual defect is that VDE treats the screen-reader announcement copy as an actionable download link.
Proposed resolution
Ignore automatic-download links that are inside #drupal-live-announce.
The live region is only a screen-reader mirror of the status message and should not be treated as an actionable UI trigger.
For example:
if (link.closest('#drupal-live-announce')) {
return;
}
This allows the real automatic-download link to work normally while preventing the announcement copy from triggering a second download during later AJAX behavior attachments.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | views_data_export-duplicate-auto-download-3621994-3.patch | 568 bytes | ssawafta |
Comments
Comment #2
ssawafta commentedComment #3
ssawafta commentedComment #4
ssawafta commentedComment #5
ssawafta commentedComment #6
ssawafta commentedComment #7
ssawafta commented