baoagency / polaris_view_components

ViewComponents for Polaris Design System
https://polarisviewcomponents.org
MIT License
380 stars 53 forks source link

Save bar doesn't show when updating `form.polaris_text_field type: :number` value using stepper arrows #449

Open BaggioGiacomo opened 1 month ago

BaggioGiacomo commented 1 month ago

You can add the save bar by adding data-save-bar=true on the form (more info here) If you add a form with a numeric input type (form.polaris_text_field type: :number) it works correctly if changing the value by writing a new number manually. If you update the value using the stepper arrows, the save bar doesn't appear

The problem here is that the event is actually fired by bubbles property is missing.

Here's a workaround to temporary fix this:

input.addEventListener("change", (event) => {
  if (!event.bubbles) {
    input.dispatchEvent(
      new Event("change", {
        bubbles: true,
      })
    );
  }
});