From 7dd4455dc275b00a94236868fce0b362521c124f Mon Sep 17 00:00:00 2001 From: Kirill Platonov Date: Fri, 22 Apr 2022 15:50:55 +0300 Subject: [PATCH] Add missing "change" event for TextInput's clear button --- app/assets/javascripts/polaris_view_components.js | 4 ++++ .../polaris_view_components/text_field_controller.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/app/assets/javascripts/polaris_view_components.js b/app/assets/javascripts/polaris_view_components.js index e2c2326a..25faa187 100644 --- a/app/assets/javascripts/polaris_view_components.js +++ b/app/assets/javascripts/polaris_view_components.js @@ -2402,7 +2402,11 @@ class TextField extends Controller { this.valueValue = this.inputTarget.value; } clear() { + const oldValue = this.value; this.value = null; + if (this.value != oldValue) { + this.inputTarget.dispatchEvent(new Event("change")); + } } increase() { this.changeNumber(1); diff --git a/app/assets/javascripts/polaris_view_components/text_field_controller.js b/app/assets/javascripts/polaris_view_components/text_field_controller.js index 737efef2..9ecea445 100644 --- a/app/assets/javascripts/polaris_view_components/text_field_controller.js +++ b/app/assets/javascripts/polaris_view_components/text_field_controller.js @@ -26,7 +26,12 @@ export default class extends Controller { } clear() { + const oldValue = this.value this.value = null + + if (this.value != oldValue) { + this.inputTarget.dispatchEvent(new Event('change')) + } } increase() {