nsw-design-system 3.18.10 → 3.18.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/js/main.js CHANGED
@@ -1799,7 +1799,6 @@
1799
1799
  this.element.addEventListener('click', this.handleFileRemove.bind(this));
1800
1800
  }
1801
1801
  handleInputChange() {
1802
- if (this.input.value === '') return;
1803
1802
  this.updateFileList();
1804
1803
  }
1805
1804
  createFileList() {
@@ -1823,6 +1822,19 @@
1823
1822
  return li.outerHTML;
1824
1823
  }
1825
1824
  updateFileList() {
1825
+ if (this.input.files.length === 0) {
1826
+ // If there are previously stored files, re-sync the input and exit.
1827
+ if (this.currentFiles && this.currentFiles.files && this.currentFiles.files.length > 0) {
1828
+ this.input.files = this.currentFiles.files;
1829
+ return;
1830
+ }
1831
+ // Clear list if otherwise
1832
+ if (this.filesList) {
1833
+ this.filesList.innerHTML = '';
1834
+ this.filesList.classList.remove('active');
1835
+ }
1836
+ return;
1837
+ }
1826
1838
  if (!this.filesList) {
1827
1839
  this.createFileList();
1828
1840
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.18.10",
3
+ "version": "3.18.11",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/js/main.js",
6
6
  "types": "dist/js/main.d.ts",
@@ -26,7 +26,6 @@ class FileUpload {
26
26
  }
27
27
 
28
28
  handleInputChange() {
29
- if (this.input.value === '') return
30
29
  this.updateFileList()
31
30
  }
32
31
 
@@ -55,6 +54,20 @@ class FileUpload {
55
54
  }
56
55
 
57
56
  updateFileList() {
57
+ if (this.input.files.length === 0) {
58
+ // If there are previously stored files, re-sync the input and exit.
59
+ if (this.currentFiles && this.currentFiles.files && this.currentFiles.files.length > 0) {
60
+ this.input.files = this.currentFiles.files
61
+ return
62
+ }
63
+ // Clear list if otherwise
64
+ if (this.filesList) {
65
+ this.filesList.innerHTML = ''
66
+ this.filesList.classList.remove('active')
67
+ }
68
+ return
69
+ }
70
+
58
71
  if (!this.filesList) {
59
72
  this.createFileList()
60
73
  }