Skip to content

Commit

Permalink
fix: add handling when user clicks cancel during csv import (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin authored Dec 12, 2022
1 parent 98fb57f commit f998418
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/apps/content-editor/src/app/views/CSVImport/CSVImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ class CSVImport extends Component {

handleFile = (evt) => {
evt.preventDefault();

// Do nothing if no file was selected because onChange gets triggered even if
// cancel button was clicked
if (!evt.target.files.length) {
return;
}

const csvToParse = evt.target.files[0];

// make sure we have a csv and throw an error if we dont
if (csvToParse.name.slice(-3).toLowerCase() !== "csv") {
return this.setState({
Expand Down

0 comments on commit f998418

Please sign in to comment.