From 011949e7574838417b80e23afcdb077480f167d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulay?= Date: Fri, 19 Jun 2020 18:30:29 -0400 Subject: [PATCH] Fix image with same pathname not updated && add boolean in onechange --- src/dat/controllers/ImageController.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dat/controllers/ImageController.js b/src/dat/controllers/ImageController.js index f4ce55f..4f369f9 100644 --- a/src/dat/controllers/ImageController.js +++ b/src/dat/controllers/ImageController.js @@ -29,6 +29,8 @@ class ImageController extends Controller { constructor(object, property) { super(object, property); + this.__onChangeFirstTime = true; + this.__fileReader = new FileReader(); const _this = this; @@ -62,7 +64,8 @@ class ImageController extends Controller { _this.__imagePreview.src = _this.__image.src; if (_this.__onChange) { - _this.__onChange.call(_this, _this.__image); + _this.__onChange.call(_this, _this.__image, _this.__onChangeFirstTime); + _this.__onChangeFirstTime = false; } } @@ -71,6 +74,7 @@ class ImageController extends Controller { if (!file) { return; } + _this.__input.value = ''; _this.__fileReader.readAsDataURL(file); }