chore(DualListSelector): convert examples to TypeScript#7458
Merged
tlabaj merged 5 commits intopatternfly:mainfrom Jun 13, 2022
Merged
chore(DualListSelector): convert examples to TypeScript#7458tlabaj merged 5 commits intopatternfly:mainfrom
tlabaj merged 5 commits intopatternfly:mainfrom
Conversation
Collaborator
|
Preview: https://patternfly-react-pr-7458.surge.sh A11y report: https://patternfly-react-pr-7458-a11y.surge.sh |
Contributor
|
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
reviewed
Jun 8, 2022
Contributor
nicolethoen
left a comment
There was a problem hiding this comment.
One nit - looks great to me!
packages/react-core/src/components/DualListSelector/examples/DualListSelector.md
Outdated
Show resolved
Hide resolved
010399d to
927a627
Compare
nicolethoen
approved these changes
Jun 8, 2022
tlabaj
approved these changes
Jun 13, 2022
Collaborator
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: