Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

emilpapelas4@gmail.com's avatar

Issue with adding new option when add a dynamic select.

When i add a new dynamic select and i chose the same option that was already in the selects array Example: { id: '1', name: 'Contact Info > Provide Email Address', value: '0.05' }, i get the default option that was { id: '0', name: 'Please Select an action', value: '0' },

changeOption(selectId, newOptionId) {
  console.log('Change Option: selectId', selectId, 'newOptionId', newOptionId);

  const selectIndex = this.selects.findIndex((select) => select.id === selectId);

  setTimeout(() => {
    const selectedOption = this.options.find((option) => option.id === newOptionId);
    if (selectedOption && selectIndex !== -1) {
      const updatedSelect = {
        id: selectId,
        name: selectedOption.name,
        value: selectedOption.value,
      };

      // Update both arrays
      this.selects[selectIndex] = updatedSelect;

      const actionIndex = this.selectedActions.findIndex((action) => action.id === selectId);
      if (actionIndex !== -1) {
        this.selectedActions[actionIndex] = updatedSelect;
      } else {
        this.selectedActions.push(updatedSelect);
      }

      this.selects = [...this.selects];
      this.selectedActions = [...this.selectedActions];
    }

    console.log('Action changed', this.selects);
  }, 0);
},
0 likes
2 replies
emilpapelas4@gmail.com's avatar

Still getting same issue and i can't fix it, Please help me guys any help is appreciated.

Please or to participate in this conversation.