-
Notifications
You must be signed in to change notification settings - Fork 6
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
DSD-1708: TagSet update to allow more properties in the data object #1545
DSD-1708: TagSet update to allow more properties in the data object #1545
Conversation
… it in the onclick function
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
type="filter" | ||
/> | ||
); | ||
|
||
screen.getByText("Blue").click(); | ||
expect(currentLabel).toEqual("Blue"); | ||
expect(currentTag).toEqual({ label: "Blue", id: "blue", field: "color" }); |
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.
As an example, the returned data is the entire data object for the tag that was clicked.
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.
great! i'm surprised the typing on the onClick doesn't complain about the extra properties.
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.
I added [key: string]: string;
to the prop definition so it's somewhat open for more values (it just won't work if it was field: 2
since that's a number...)
Returning the entire object is definitely an upgrade! The question of the return value for clear filters is less straightforward. With the tagset as it is, the onchange has to expect categorically different data, either the tag you removed, or a message indicating that the tags have been cleared. |
This update is intended to be a fundamental change because it's going into v3.0 so breaking change are okay, it just need to be documented. The suggestion makes sense but to be clear, are these examples correct?
This makes sense. It might also help remove the internal |
Ok! In that case, that example is doing what I'm talking about. And when you say return, I assume you mean that's what gets passed into the onChange? |
Yes, but it's
|
Here's another idea, the
|
Yea I agree that we shouldn't let the specific use case of the RC determine what the behavior should be. I like the idea of providing two arguments, but that leads back to the issue of clear filters passing an argument that needs special handling. I'm also wondering if maybe another solution to this is to have an onClick and onClear as two separate callbacks. |
I like the idea of breaking it up to two functions to make it clearer. The |
I think it is important to know which tag was clicked and therefore removed. I can imagine a number fo use cases where this would a useful detail. And if As for |
I updated to return the clicked tag that was removed. Check out the updated working example in storybook for the action and the code and let me know what you think @bigfishdesign13 @charmingduchess https://nypl-design-system-git-dsd-1708-tagset-callback-value-nypl.vercel.app/?path=%2Fdocs%2Fcomponents-form-elements-tagset--docs |
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.
This looks good to me, but I will alllow @charmingduchess to give the final approval here. I just had one concern about how you refer to one of the props.
src/components/TagSet/TagSet.mdx
Outdated
@@ -102,34 +102,75 @@ Notes: | |||
- The `isDismissible` prop is optional and the `onClick` prop is required for |
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.
The onClick
prop for the "filter"
variant has a ?
, so it is optional.
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.
This was always optional. The onClick
prop is only applicable when isDismissible
is true.
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.
But you say onClick
is required. Did you mean it is required when isDismissible
is true?
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.
Ah, I see. This wasn't updated in this pr but I'll update it.
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.
Oh, you're right. Sorry about that. Thanks for making the update.
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!
Fixes JIRA ticket DSD-1708
This PR does the following:
onClick
function now returns the entire tag data object in the callback function argument instead of just the tag's label.How has this been tested?
Locally and through an example.
Accessibility concerns or updates
Checklist:
Front End Review: