-
Notifications
You must be signed in to change notification settings - Fork 377
chore(DualListSelector): convert examples to TypeScript #7458
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
chore(DualListSelector): convert examples to TypeScript #7458
Conversation
|
Preview: https://patternfly-react-pr-7458.surge.sh A11y report: https://patternfly-react-pr-7458-a11y.surge.sh |
|
Ah, so stringify was being used here to do a deeper comparison between the complex objects. @kmcfaul I think you were the one who landed on this solution here? |
17b5206 to
010399d
Compare
nicolethoen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit - looks great to me!
packages/react-core/src/components/DualListSelector/examples/DualListSelector.md
Outdated
Show resolved
Hide resolved
010399d to
927a627
Compare
kmcfaul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #7396
Dual list selector preview build
Updated comment
Per my original comment below, I utilized
JSON.stringy's replacer argument to resolve the error that was occurring (also noted below). An alternative could be to utilize equality checking similar to how to compare objects in JavaScript, which did work when I tried it out, but because you can pass in strings, objects, or HTML elements (based on the examples we provide), I wasn't sure whether we would ever need to further check whether an option is a particular type and do different checking based on that. Using this replacer argument seems like a simpler fix and it works with both the updated functional example and the class example.I also made a change to the replacer method in that it checks for any key that starts with an underscore (rather than just the specific
_ownerkey) just to be safe.Original comment below
A note on this PR
When running this code locally, the "Using more complex options with actions" causes the below error to occur whenever you try interacting with the dual list selector in the example (clicking an option, typing in the search bar, etc):
This only occurs when the
availableOptionsstate in the example is set to an array of HTML elements like<span>Option 1</span>...when the example is converted to a functional component. An array of strings works fine, and the array of HTML elements also works fine on the current example on the PF site that uses a class. From trying to look into it, the below snippet of code on lines 195-196 within DualListSelector is causing it:Utilizing JSON.stringify's replacer argument does seem to avoid this error with a function similar to below, but I haven't yet delved into figuring out why that resolves it/why the error occurs in the first place:
Because the example seems to intend to show how to use more complex options than just strings, it wouldn't seem like simply changing the options to strings would suffice here.
Additional issues: