Vue: Input file change events are not fired in Microsoft Edge

Created on 4 Apr 2018  路  3Comments  路  Source: vuejs/vue

Version

2.5.16

Reproduction link

https://jsfiddle.net/eywraw8t/13868/

Steps to reproduce

Outlined in the JSFiddle

What is expected?

A change event to be fired when a file is selected in the Edge browser.

What is actually happening?

No change event is fired when the input is triggered from within Vue.


This might just be a bug with Edge but because it does behave correctly outside of Vue it leads me to believe that there is an issue between the two somewhere.

Most helpful comment

The problem seems to be that the popup window to select a file happen before the change event is registered in Internet Explorer. So that is the reason why it doesn't work the first time.

But, the real problem is that you register a new change event each time the "upload" method is called. You will notice that the alert will popup many time if you keep selecting files.

The solution is to declare the change event outside and everything works. Here is a fixed fiddle:
https://jsfiddle.net/eywraw8t/13921/

All 3 comments

The problem seems to be that the popup window to select a file happen before the change event is registered in Internet Explorer. So that is the reason why it doesn't work the first time.

But, the real problem is that you register a new change event each time the "upload" method is called. You will notice that the alert will popup many time if you keep selecting files.

The solution is to declare the change event outside and everything works. Here is a fixed fiddle:
https://jsfiddle.net/eywraw8t/13921/

Closing based on @Gudradain having a solution in user land

You're triggering the click event before adding the change event. Also, what @Gudradain said

Was this page helpful?
0 / 5 - 0 ratings