You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is a bug that if a user sets their own regex expression within onServerSearch(...), the correct results are no longer displayed. See reprex here -https://codepen.io/MichalLauer/pen/XWQOVpo. There, I am using a custom regex to search and return values (line 5). For example, if you search for "c b a", I want to return all items that contain "c", "b", and "a". The regex correctly identifies them and prints them (lines 8 - 10). So the contents of onServerSearch are correct. However, nothing is printed in the virtual select.
This happens even in cases without regex. For example, if I wanted to always show only the first option, the VirtualSelect shows items based on the default search function - https://codepen.io/MichalLauer/pen/JjVxxXK. In the second reprex, no matter what you search for, the only option visible should always be "a b c". However, searching for items such as "i" returns "i j k". The custom function works in both cases correctly, which can be checked in the console where only visible options are printed.
The text was updated successfully, but these errors were encountered:
MichalLauer
changed the title
Custom regex in onServerSearch is not respected
Custom values in onServerSearch are not respected
Apr 25, 2024
I was not able to identify what exactly causes the issue, but a temporary solution is to replace the virtualSelect.setServerOptions(newOptions); call with the same code but exclude this.setVisibleOptionsCount(); calls.
functionsearchLabel(searchValue,virtualSelect){
...
// --/** merging already selected options details with new options */if(selectedOptions.length){constnewOptionsValueMapping={};optionsUpdated=true;newOptions.forEach((d)=>{newOptionsValueMapping[d.value]=true;});selectedOptions.forEach((d)=>{if(newOptionsValueMapping[d.value]!==true){// eslint-disable-next-line no-param-reassignd.isVisible=false;newOptions.push(d);}});virtualSelect.setOptionsMethod(newOptions,true);}if(optionsUpdated){if(virtualSelect.multiple){virtualSelect.toggleAllOptionsClass();}virtualSelect.setValueText();}else{virtualSelect.updatePosition();}functionremoveServerSearchingClass($allWrappers){// Convert $allWrappers to a jQuery objectconst$jqueryAllWrappers=$($allWrappers);$jqueryAllWrappers.removeClass('server-searching');}removeServerSearchingClass(virtualSelect.$allWrappers);virtualSelect.visibleOptionsCount= ...;// manually compute the number of visible itemsvirtualSelect.afterSetVisibleOptionsCount();// --}
Hello,
there is a bug that if a user sets their own regex expression within
onServerSearch(...)
, the correct results are no longer displayed. See reprex here -https://codepen.io/MichalLauer/pen/XWQOVpo. There, I am using a custom regex to search and return values (line 5). For example, if you search for "c b a", I want to return all items that contain "c", "b", and "a". The regex correctly identifies them and prints them (lines 8 - 10). So the contents ofonServerSearch
are correct. However, nothing is printed in the virtual select.This happens even in cases without regex. For example, if I wanted to always show only the first option, the VirtualSelect shows items based on the default search function - https://codepen.io/MichalLauer/pen/JjVxxXK. In the second reprex, no matter what you search for, the only option visible should always be "a b c". However, searching for items such as "i" returns "i j k". The custom function works in both cases correctly, which can be checked in the console where only visible options are printed.
The text was updated successfully, but these errors were encountered: