Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting non-existent option throws error in v1.13.10 #2263

Closed
Stoneguard001 opened this issue Apr 23, 2019 · 10 comments
Closed

Selecting non-existent option throws error in v1.13.10 #2263

Stoneguard001 opened this issue Apr 23, 2019 · 10 comments

Comments

@Stoneguard001
Copy link

The system assigns the previous selected option to a variable, then sets selected to false. But if that value is -1, an undefined variable causes the code to crash.

This occurred anywhere I was using a data-live-search=true value and there was no default selection value. The fix is to simply check for undefined on the variable

if (!that.multiple) { // Deselect all others if not multi select box
  if (prevOption !== undefined) {
     prevOption.selected = false;
  }
@caseyjhol
Copy link
Member

It shouldn't ever be possible for a single select to not have a selected option (i.e. selectedIndex should never be -1). That being said, what should be possible, and what is actually possible are often different. Could you provide me with an example? Or let me know the browser you are encountering this issue with?

@ghost
Copy link

ghost commented Apr 25, 2019

Hi, Don't know if this helps but I'm having the same issue when using version 1.13.10 but I DONT have the issue when using 1.13.9. I'm not using data-live-search but it's happening in IE11 & Chrome on any single select list with nothing selected.

@Stoneguard001
Copy link
Author

I tried working with this last night on a jsfiddle but could not re-create it. I will check what version of bootsrtap-select it is using and see what I can do to duplicate it

@felixvictor
Copy link

I have the same issue. My unchanged code doesn't work with 1.13.10 but does work with 1.13.9.

@giero
Copy link

giero commented May 9, 2019

Same problem :(

Here's an example: https://jsfiddle.net/bp9hy1sz/

@Stoneguard001
Copy link
Author

Thank you! Not sure why I could not get my jsfiddle to work.

@PhilPJL
Copy link

PhilPJL commented May 21, 2019

Same issue here. Works with 1.13.9, not with 1.13.10. Setting data-title is a work around.

@vandetho
Copy link

vandetho commented Jul 11, 2019

Another solution would be to add an empty option tag with selected attribute.

@caseyjhol
Copy link
Member

Another example:

In Version 1.13.10

Here the bug:

When you select a non existing option by code in select, it breaks the selection by hand:

Here a code pen of the issue.

Here the v1.13.9 code pen working

@caseyjhol caseyjhol changed the title single select dynamic list can crash when no selection Selecting non-existent option throws error in v1.13.10 Aug 1, 2019
@caseyjhol
Copy link
Member

Released in v1.13.11!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants