Searching of Dropdown Values Includes Tags in Rendered HTML

Hello

I’ve got a searchable, select2 dropdown configured which presents rendered HTML to enable the inclusion of superscript and subscript characters on scientific values.

Example values:

  • A
  • A{sup}M{/sup} <- with angle brackets instead of braces, obviously
  • S

Rendered as

  • A
  • AM
  • S

When I expand the dropdown and type S, I would intuitively expect it to only show S, but the search control is searching within the HTML tags to includes AM.

That’s odd, but I have confirmed the behavior you described. I guess the Select2 author(s) didn’t expect that item text would include HTML tags.

You will need to create a custom matcher that extracts just the text of the item and matches against that.

1 Like