mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
fix: use e.currentTarget instead of this in download link click handler
Cast to HTMLAnchorElement for precise typing of .id and .href. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3031,13 +3031,14 @@
|
||||
"click.shinyDownloadLink auxclick.shinyDownloadLink",
|
||||
"a.shiny-download-link",
|
||||
function(e4) {
|
||||
if (this.classList.contains("disabled")) {
|
||||
const el = e4.currentTarget;
|
||||
if (el.classList.contains("disabled")) {
|
||||
e4.preventDefault();
|
||||
return;
|
||||
}
|
||||
const evt = import_jquery25.default.Event("shiny:filedownload");
|
||||
evt.name = this.id;
|
||||
evt.href = this.href;
|
||||
evt.name = el.id;
|
||||
evt.href = el.href;
|
||||
(0, import_jquery25.default)(document).trigger(evt);
|
||||
}
|
||||
);
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
inst/www/shared/shiny.min.js
vendored
2
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -38,16 +38,18 @@ $(document).on(
|
||||
"click.shinyDownloadLink auxclick.shinyDownloadLink",
|
||||
"a.shiny-download-link",
|
||||
function (e: Event) {
|
||||
const el = e.currentTarget as HTMLAnchorElement;
|
||||
|
||||
// Prevent clicks when the button is disabled.
|
||||
if ((this as HTMLElement).classList.contains("disabled")) {
|
||||
if (el.classList.contains("disabled")) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
const evt: FileDownloadEvent = $.Event("shiny:filedownload");
|
||||
|
||||
evt.name = this.id;
|
||||
evt.href = this.href;
|
||||
evt.name = el.id;
|
||||
evt.href = el.href;
|
||||
$(document).trigger(evt);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user