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
{{ message }}
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Search highlight appears wrong when entering second word or backspacing #1149
I've been trying to get to the root of this, initially believing it was a styling issue which could be easily remedied, but alas, it seems to be more insidious.
As soon as I type a word, then a space, then enough of the next word to cause a shift in matches, the original word is deleted from any matches thereafter, until I refresh the page.
It doesn't seem to happen with small datasets (I think).
Furthermore, when I type then delete all letters in a search, the first letter is still shown as highlighted in the list:
This removes visual highlighting altogether but fixes the aforementioned issues. Until I have more time to debug I'll be leaving it at is, unless someone else lends it the time :)
changed the title [-]search word deleting matching words in option list[/-][+]Search highlight appears wrong when entering second word or backspacing[/+]on Sep 12, 2016
The highlight function really seems to be badly broken. The issue also appears on the demo page in the email contacts example.
I've attached a GIF showing the error.
For now I'm going to disable the highlighting in my project.
This highlighting issue (and #1142) can be fixed by ensuring that Selectize doesn't attempt to highlight already-highlighted areas, creating nested spans, e.g. <span class="highlight">B<span class="highlight">r</span>ian</span>
This can be prevented by adding an additional condition: ( node.className !== 'highlight' || node.tagName !== 'SPAN' )
I built from master and am still having issue with this, Part of the first word gets deleted.
"Mile End" becomes "Mil End" and only End is highlighted. This is not what is received from the server.
Also the way it is filtering is counter intuitive. I want a right phase search rather an 'or' search with two word. So the cache filtering don't match how the server is searching.
closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.
Activity
kylegillen commentedon Sep 7, 2016
Quick update. I've narrowed it down to this line in the highlight function:
middlebit.parentNode.replaceChild(spannode, middlebit);This removes visual highlighting altogether but fixes the aforementioned issues. Until I have more time to debug I'll be leaving it at is, unless someone else lends it the time :)
[-]search word deleting matching words in option list[/-][+]Search highlight appears wrong when entering second word or backspacing[/+]scroach commentedon Oct 4, 2016
The highlight function really seems to be badly broken. The issue also appears on the demo page in the email contacts example.
I've attached a GIF showing the error.
For now I'm going to disable the highlighting in my project.
micahjon commentedon Nov 2, 2016
This highlighting issue (and #1142) can be fixed by ensuring that Selectize doesn't attempt to highlight already-highlighted areas, creating nested spans, e.g.
<span class="highlight">B<span class="highlight">r</span>ian</span>This can be prevented by adding an additional condition:
( node.className !== 'highlight' || node.tagName !== 'SPAN' )to this line:
https://github.com/selectize/selectize.js/blob/master/src/contrib/highlight.js#L28
If you'd like, I can run the tests and submit a PR.
joallard commentedon Nov 3, 2016
Absolutely!
Fix highlighting bugs selectize#1149 and selectize#1142 by preventing…
Merge pull request #1193 from pranksinatra/bugfix-highlight
Fix highlighting bugs selectize#1149 and selectize#1142 by preventing…
x00 commentedon Jun 8, 2017
I built from master and am still having issue with this, Part of the first word gets deleted.
"Mile End" becomes "Mil End" and only End is highlighted. This is not what is received from the server.
Also the way it is filtering is counter intuitive. I want a right phase search rather an 'or' search with two word. So the cache filtering don't match how the server is searching.
x00 commentedon Jun 8, 2017
Here is an example
just try typing "Mile End" once you get to "Mile En" it appears as "Mil End"
Vaccano commentedon Jan 16, 2018
I am still having this issue in the current version. It stems from the highlight code trying to re-highlight text that has already been highlighted.
Adding this fixed that error:
I added that after these lines in the highlight function:
Fleuv commentedon Feb 16, 2018
The bug regarding the option remaining highlighted after search still exists.
Downloaded Selectize standalone yesterday (v0.12.4)
RicardoRamirezR commentedon Apr 6, 2018
Yes, the bug is still there in (v0.12.4), see JSFiddle type
blanco cafeBut applying @Vaccano fix works!
Fix selectize#1149
risadams commentedon Nov 30, 2020
closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.
rvaldemar commentedon Mar 28, 2021
last version has this problem solved