-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Tag] Clarify that onClick and onRemove are mutually exclusive #2987
Conversation
🟢 This pull request modifies 3 files and might impact 3 other files. Details:All files potentially affected (total: 3)📄
|
d3337b3
to
95d933b
Compare
Would it be useful to actually remove the tag in the example? |
It's moreso illustrating that setting |
Could we also help enforce this in the Typescript declaration of Tag's props? TextField does similar where you can have only one of |
Marc did that for |
95d933b
to
d2449e5
Compare
Cool, ignore me :) |
It feels a little odd for the demo of removable tag to not show any on initial render, but to instead show an autocomplete box.Doesn't fee very useful for our VRT stuff. How about something like this as an example: function RemovableTagExample() {
const [selectedTags, setSelectedTags] = useState([
'Rustic',
'Antique',
'Vinyl',
'Refurbished',
]);
const removeTag = useCallback(
(tag) => () => {
setSelectedTags((previousTags) =>
previousTags.filter((previousTag) => previousTag !== tag),
);
},
[],
);
const tagMarkup = selectedTags.map((option) => (
<Tag key={option} onRemove={removeTag(option)}>
{option}
</Tag>
));
return <Stack spacing="tight">{tagMarkup}</Stack>;
} |
d2449e5
to
091c175
Compare
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.
Code looks good to me 🥇 Thank Chloe!
@kyledurand Would you mind merging this for me? I don't have admin privileges and the pa11y failures don't have anything to do with this PR (the autocomplete is setting |
I can merge for you but I'd prefer if you could add those two failing ids to our accessibility checks list https://github.com/Shopify/polaris-react/blob/master/scripts/accessibility-check.js#L88 |
4eab9e5
to
9e09ba7
Compare
c60ccba
to
b222df9
Compare
No need to fixup a11y tests skip lists if we've already fixed all our failing a11y tests :thonk: I've updated the removable example per my above comment so that it demos tags immediately rather than needing you to interact with an autocomplete |
b222df9
to
e08b0b0
Compare
* [Tag] Clarify that onClick and onRemove are mutually exclusive * Shorter, clearer removable tag example Co-authored-by: Ben Scott <ben.scott@shopify.com>
WHY are these changes introduced?
#2986 brought to my attention that there isn't a removable tag example, and that it needs to be documented that clickable tags aren't removable.
WHAT is this pull request doing?
This PR adds a removable tag example and clarifies that the remove button doesn't render when
onClick
is set.***Note: The pa11y test failure is due to a bug reported with
Autocomplete
.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes