The fwChange event getting triggered twice per change in the dropdown field

Hi Team

I have a fwChange event in the dropdown field. In this event’s callback function, I have some business logic. but this fwChange event is getting triggered twice per change in that dropdown field. I’m sure I have only one event listener for that dropdown element. It’s not happening all the time. If this occurs, I’ll be able to get previous and current values from this event parameter(event.target.value). I have faced this issue many times in the custom app.

index.html

 <fw-select
                    label="my select"
                    id="select"
                    placeholder="select"
                    required="true"
                  >
                    <fw-select-option value="option 1"
                      >option 1</fw-select-option
                    >
                    <fw-select-option value="option 2">
                      option 2</fw-select-option
                    >
                    >
                    <fw-select-option value="option 3"
                      >option 3</fw-select-option
                    >

                    <fw-select-option value="option 4"
                      >option 4</fw-select-option
                    >
                  </fw-select>

app.js

document
  .getElementById("select")
  .addEventListener("fwChange", eventHandler);

function eventHandler(event) {
  console.log(event.target.value);
  console.log("called ");
}

image
Here, I selected option 3 in the dropdown field.


It logs previous and current values in the console.

Any help will be appreciated. Thanks in advance.

Hey @Kithiyon,

I have tried reproducing it, and I couldn’t. It always prints only once. What is the version that you use in Crayons? I used v4 to test.

Does it occur as a custom app as well?
Is it possible for your computer to be slow while testing the app? This particular script runs on the browser, and if the environment is slow, there can be chances for the event listener to get added twice.
Do you see any pattern when this issue occurs?

Thank you @Raviraj

I’m using Crayons v3, and I tried v4 too.

I think slowness is not the issue because I packed my app and shared it with my colleague. He deployed it as a custom app in his account and tested it on his machine. He also faced the same issue. I’m wondering if I missed something in my HTML file.Can I connect with your team to discuss this?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.