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

Multiselect May Break When Values are Strings With Certain Characters #155

Open
iamjohnford opened this issue Apr 25, 2024 · 3 comments
Open

Comments

@iamjohnford
Copy link

The multiselect example code uses integers for the values of the fields but when using strings with certain characters like ' the JavaScript can sometimes have trouble. Issues may also appear with > due to character encoding when the chip partial is trying to find a match.

To Reproduce

Add something like this to the multiselect_prefilled_form example:

display: Test Option
value: Contriv'ed > Example

May need to try with Test Option preloaded and also try to add/remove it from the list.

Certain code like the following will break because value contains a quote and would need escaping:

  // options.js
  _optionElementWithValue(value) {
    return this._actingListbox.querySelector(`[${this.filterableAttributeValue}][data-value='${value}']`)
  }
@josefarias
Copy link
Owner

Hey @iamjohnford thanks for the report. I'm curious — what's the use-case for this? What are you using as your values?

@iamjohnford
Copy link
Author

It's a fairly unique scenario with some imported client data from an external system without ids attached to the text. So, the key and value of the list are both the text value. We actually had data that looked like the example I mentioned just with real client data (Contriv'ed > Example). There were apostrophes and greater than symbols.

I realize this scenario might be a bit too unique to make coding changes for.

@josefarias
Copy link
Owner

I see. Thanks for sharing. I'll explore how much the code would need to change. I don't see a reason not to support this unless it requires too much code.

In the meantime, I wonder if encoding your values in a deterministic way would be a good stopgap. I haven't used it, but https://github.com/hopsoft/universalid might be a good option. Or just a plain-old native URL/base64 encoding.

I'll keep this open as a reminder to explore this.

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

2 participants