Skip to content

Commit

Permalink
Merge pull request #362 from shuhaib-aot/Feature/Enabled-drag-and-dro…
Browse files Browse the repository at this point in the history
…p-for-file-upload

Added drag and drop for import
  • Loading branch information
arun-s-aot authored Dec 9, 2024
2 parents 3418d1e + dcaeee9 commit f95ba3d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,20 @@ export const ImportModal: React.FC<ImportModalProps> = React.memo(
role="button"
className="file-upload"
tabIndex={0}
onDragOver={(e) => {
e.preventDefault(); // Prevent the browser's default drag behavior
e.stopPropagation();
}}

onDrop={(e) => {
e.preventDefault();
e.stopPropagation();
const file = e.dataTransfer.files[0];
if (file) {
setSelectedFile(file); // Handle the dropped files
}
}}

onClick={() => document.getElementById("file-input")?.click()}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
Expand Down

0 comments on commit f95ba3d

Please sign in to comment.