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 ");
}
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.