Wix dropdown display bug in preview

Problem: When code sets dropdown options, the dropdown display is not updated in preview mode.

To demonstrate:

Make a test page with a dropdown and a button

Add this code:

function setup() {
$w(“#dropdown1”).options = [
{ “label”: “Who’s on first!”, “value”: “first” },
{ “label”: “What’s on second”, “value”: “second” },
{ “label”: “I Don’t Know is on third”, “value”: “third” }
];
}

export function button1_click(event) {
setup();
console.log(“$w(‘#dropdown1’).options:”,$w(‘#dropdown1’).options)
}

To test:

  1. Preview the page

  2. Click the drop down and note the default choices

  3. Click the button

  4. Click the drop down and note the default choices are still there.

  5. Look at the console output and notice the the dropdown options are what they were set to.

  6. Publish the site and run the same test on the public site.

  7. Note that the dropdown now shows the proper choices.

I have made a demo site: https://sigpoggy.wixsite.com/my-site

Try this…

$w.onReady(()=>{setup();})

function setup() {
    $w("#dropdown1").options = [
        { "label": "Who's on first!", "value": "first" },
        { "label": "What's on second", "value": "second" },
        { "label": "I Don't Know is on third", "value": "third" }
    ];
}

That work around does not work for me because a lot of my other code has to execute before I init several drop downs due to various dependencies. This problem only showed up in the last week or two. All my projects with similar code broke in preview mode.

The only work around that lets me debug with out going live is to duplicate the website and test it live there. Not a pleasant work flow.

@sigpoggy
Perhaps it has something to do with this…
https://www.wix.com/velo/forum/community-discussion/why-isn-t-my-html-element-showing-on-my-dynamic-pages

@sigpoggy Are you still having this issue? Our QA team investigated and didn’t find any problems, so hopefully it was just a temporary issue that has since resolved.

Yes I’m still having issues. The problem seems to be intermittent at this point. I have seen it come and go several times and can find no way to either make it always work or always fail.

Yesterday when I started developing, it worked at first. I was able to debug in preview mode for awhile since setting options was working, but hit a wall when selectedIndex failed in a light box. I decided to restart the editor since that sometimes clears up various problems that arise. But then the original problem came back.

I checked my simple demo and added code to test setting selectedIndex. Everything worked ok in the demo. I restarted the editor and it still worked.

I considered that since my page has a lot of code and elements I might be overwhelming the system. However, in prepping this reply just now, I went back to the demo and tried it again and it failed.

I have been forced to test live in a duplicate of the site to get the job finished which was about an hour ago.

Here is one thing that does not seem to change in my demo app.
When I run the app for the first time after starting up the editor and I console log the options of the dropdown in onReady, it shows the default values.

I then set the options to different values and exit preview mode. Then I run the app again and console log now shows the second set of values rather than the default values in the onReady function.

This should not be happening. The results of the previous code run should not change initial values of the next code run. It requires restarting the editor to get back to the default options showing up.

@sigpoggy OK, thanks for letting me know. I’ll report back to QA.

@sigpoggy Hi. Thank you for sharing this information.
Unfortunately, I wasn’t able to reproduce the issue in preview mode. I also tried on your test site - same thing.

Any chance you could add a video fragment of the problem once you be able to reproduce it on your side? That would be very helpful.

Regards, Alex

@aleksander-denga Here is the requested video. Note that this problem only showed up in the past few weeks on code that had been working ok in the preview mode for at least six months.
Further details just in case (though should not really matter):
I’m on an iMac running MacOS 10.15.7 using Chrome Version 88.0.4324.192

I am running into the same issue of dropdowns not populating in Preview mode. I have seen this behavior within the past hour (CST US). It seems to be directly related to setting the .selectedIndex attribute to any number (0 to length of the options array). If I comment out setting the selectedIndex, the dropdown populates. Does not matter if values come from a hard coded array, a collection, or the results of a function. If I publish the site with the selectedIndex set, it works as expected in Live.

@sigpoggy Thank you. I reported both issues to our development team to handle. However, can’t promise a quick solution here.

So, I’d suggest to use a live version of your site for debugging purposes for now, since this flow works there. Of course, if that is appropriate for your case.
Kind regards, Alex

@aleksander-denga Why do we even have preview mode if it’s so unreliable?
This issue is still present today (29/08) as i have just spent 30 minutes trying to figure out what the problem is before finding this thread. This is not the only issue in preview that forces us devs to use live view instead. And what about the times where we actually need to use preview so we can use sandbox data and / or cannot affect live data?!
You have been made aware of the issue in enough detail and acknowledged it but 5 months later its still an issue?!

seconded (well third). I have experienced this issue now also.