[Crayons] Unable to update fw-select options after page load

We have a scenario where the options of a fw-select element are dynamically populated based off of other fields. However, when we set the options property on the fw-select element, the specified fw-select-option elements do not created. However, when the operation runs under 50 ms of page load, the fw-select operates as expected. Listed below is a simplified recreation of the issue. The expected behavior of the below code is for the dropdown to have three values: Luffy, Zorro, and Sanji. What is currently happening is the dropdown contains no fw-select-options.

<!DOCTYPE html>
<html lang="en">

<head>
  <script type="module" src="https://unpkg.com/@freshworks/crayons@v3/dist/crayons/crayons.esm.js"></script>
  <script nomodule src="https://unpkg.com/@freshworks/crayons@v3/dist/crayons/crayons.js"></script>
</head>

<body>
  <fw-select name="complexSelect" label="Strawhat Pirates" multiple></fw-select>

  <script>
    setTimeout(function () {
      document.querySelector('[name="complexSelect"]').options = [
        {
          value: '1',
          text: 'Luffy'
        },
        {
          value: '2',
          text: 'Zorro'
        },
        {
          value: '3',
          text: 'Sanji'
        },
      ];
    }, 1000);
  </script>

</body>

</html>

Hi Christopher, thanks for reporting this. We are able to reproduce this issue. We will work on a fix for this. We will notify you on this thread upon releasing a fix.

2 Likes

Hi Christopher, The issue is fixed in Crayons@3.4.0-beta.0 to check replace the existing script with the below links

<script type="module" src="https://unpkg.com/@freshworks/crayons@3.4.0-beta.0/dist/crayons/crayons.esm.js"></script>
<script nomodule src="https://unpkg.com/@freshworks/crayons@3.4.0-beta.0/dist/crayons/crayons.js"></script>

A working demo is available in - JS Bin - Collaborative JavaScript Debugging

I can confirm that 3.4.0-beta.0 fixes the issue.

3 Likes

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