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

Search Optgroups #1343

Merged
merged 14 commits into from
Jul 16, 2013
Merged

Search Optgroups #1343

merged 14 commits into from
Jul 16, 2013

Conversation

pfiller
Copy link
Contributor

@pfiller pfiller commented Jul 11, 2013

@kenearley @stof @koenpunt

Exactly what it says on the label: this adds optgroups to the search mechanism. When a group matches, all of its child options are shown regardless of their match status.

This also brings in escaping for optgroup labels. There's a long outstanding XSS vulnerability that needs closing.

Fixes #298
Addresses part of #124

option.search_match = false
else

option.group_match = false if option.group
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group_match tracks whether or not a child option matches (group headers get displayed when a child option matches)

@@ -88,6 +89,10 @@ class AbstractChosen

"""<li id="#{option.dom_id}" class="#{classes.join(' ')}"#{style}>#{option.search_text}</li>"""

result_add_group: (group) ->
group.dom_id = @container_id + "_g_" + group.array_index
"""<li id="#{group.dom_id}" class="group-result">#{group.search_text}</li>"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really liking the block string syntax here. Very readable :)

@kenearley
Copy link

This is great! I like seeing more code get removed from the library specific files. There's one small non-blocking visual issue I noticed. When you type a portion of the optgroup, then select all and start typing an option, the optgroup's highlighting doesn't reset (jquery and proto versions). :shipit:

optgroup_highlight

This fixes an issue where group search text doesn't get reset
properly and simplifies the match functionality.
@pfiller
Copy link
Contributor Author

pfiller commented Jul 16, 2013

@kenearley Take a look at 1b7cd20 and re-test if you don't mind. That fixes the issue you described above and simplifies the code in a way that makes me happy. I'll merge this as soon as you re-+1.

@kenearley
Copy link

@pfiller Looks good to me. :shipit: again.

pfiller added a commit that referenced this pull request Jul 16, 2013
@pfiller pfiller merged commit a1c91a4 into master Jul 16, 2013
@pfiller pfiller deleted the option-group-sarch branch July 16, 2013 21:48
pfiller added a commit that referenced this pull request Jul 17, 2013
- Search optgroups #1343
- Change search match style #1344
- Remove memoization of search field width. #1359
- Remove Chosen's ID dependency #1360
- Rebuild Search Results After liszt:updated #1361
- Clear highlight when no results are found #1364
@suspiciousfellow
Copy link

Hey chaps, how about adding group_search to the chosen documentation?

@tjschuck
Copy link
Member

@suspiciousfellow Thanks for the heads-up! I opened #2752 to track that. Feel free to open a PR if you'd like to take a swing at it!

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

Successfully merging this pull request may close these issues.

Allow search to matche optgroup
5 participants