File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ class FileAttachmentElement extends HTMLElement {
8
8
this . addEventListener ( 'dragleave' , onDragleave )
9
9
this . addEventListener ( 'drop' , onDrop )
10
10
this . addEventListener ( 'paste' , onPaste )
11
+ this . addEventListener ( 'change' , onChange )
11
12
}
12
13
13
14
get directory ( ) : boolean {
@@ -132,3 +133,16 @@ function onPaste(event: ClipboardEvent) {
132
133
container . attach ( files )
133
134
event . preventDefault ( )
134
135
}
136
+
137
+ function onChange ( event : Event ) {
138
+ const container = event . currentTarget
139
+ if ( ! ( container instanceof FileAttachmentElement ) ) return
140
+ const input = event . target
141
+ if ( ! ( input instanceof HTMLInputElement ) ) return
142
+
143
+ const files = input . files
144
+ if ( ! files || files . length === 0 ) return
145
+
146
+ container . attach ( files )
147
+ input . value = ''
148
+ }
You can’t perform that action at this time.
0 commit comments