-
Notifications
You must be signed in to change notification settings - Fork 81
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
[FC-0036] feat: New "Add Tags" widget #834
[FC-0036] feat: New "Add Tags" widget #834
Conversation
Thanks for the pull request, @yusuf-musleh! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
b3aa084
to
6bfd13b
Compare
da28fb9
to
6fecc42
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #834 +/- ##
==========================================
- Coverage 91.30% 91.29% -0.01%
==========================================
Files 561 561
Lines 9768 9849 +81
Branches 2081 2099 +18
==========================================
+ Hits 8919 8992 +73
- Misses 816 824 +8
Partials 33 33 ☔ View full report in Codecov by Sentry. |
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.
@yusuf-musleh Looks good! Very great work! 👍
- I tested this: I followed the testing instructions
- I read through the code and considered the security, stability and performance implications of the changes.
- Includes tests for bugfixes and/or features added.
- Includes documentation
104b55f
to
76de6d5
Compare
components={{ | ||
// @ts-ignore TODO: Properly fix this | ||
Menu: CustomMenu, | ||
// @ts-ignore TODO: Properly fix this | ||
LoadingIndicator: CustomLoadingIndicator, | ||
// @ts-ignore TODO: Properly fix this | ||
IndicatorsContainer: CustomIndicatorsContainer, | ||
}} |
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 couldn't get the types to work properly here, any advice on how to properly fix this?
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.
@yusuf-musleh Sorry for the delay, I'm hoping to check out this PR and answer your question soon :)
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.
@yusuf-musleh I figure out the types for you. I meant to push them to a new branch just now, but accidentally pushed them to this same branch. Sorry about that. Please review and incorporate or not as you wish.
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.
@bradenmacdonald Thanks a lot for fixing the types! It was really tricky getting them to work. There were some more typing issues the linter was complaining about, but I fixed them here: 0200cf7
I also found a react warning in the console caused by setting state of a parent component while updating the state in the child. I spent some time looking into it and refactored it here: cdc2269 seems to be working fine now.
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.
@yusuf-musleh Nice work. This is my first time trying to include a .d.ts
file in an Open edX MFE with the same name as the .jsx
file, and frankly I'm surprised that it works at all. But it seems to solve the problem :)
@yusuf-musleh Thanks! I was looking forward to this feature :) |
cdc2269
to
603416c
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.
I've noticed a strange thing when using this code.
If I add a tag and then remove tags, the first tag seems to be getting duplicated each time I remove another tag. This seems to happen only if the first tag you added (or the alphabetically first?) is a root tag.
i.e. After adding and removing a few tags when I removed a tag this was the post JSON:
{
"tags": [
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Abilities",
"Holland Codes",
"Foundational Knowledge",
"Being Responsible",
"Skills"
]
}
Replace existing component with react-select component, by passing in our custom component. This retained the existing search functionality.
This bug appeared after removing the react-query call to the backend when selecting/unselecting a tag in the dropdown. Since it no longer gets the updated state from the backend, it doesnt mask the bug. The bug is essentially the `ContentTagsCollapsibleHelper` rerendering causing the states to reset overriding the selected (not commited) tags. This is due to missing dependancies in the useCallback.
This adds a state and callbacks in the toplevel component of the content tags drawer to be able to add/remove staged content tags and have them showup in the react-select as selected chips.
Now content tags have seperate tree states for applied ones and staged ones. They are updated seperately and both are used when updating the selectable box UI. This allows for more flexibility with actions that can be performed on the staged content tags with impacting the applied ones.
This overrides the indeterminate input checkbox style to match the checked checkbox style, using variables defined in paragon.
This implements the commit functionality for staged tags, taking account for implicit tags. This also handles the case for removing applied tags by clicking on the "x" in the TagBubble.
In the react-select component, an inline "Add" button showsup when some tags are staged, if they are clicked they are commited/applied.
Also clear search term whenever tags are staged/cancelled
This refactor removed the warning that was caused because the state of a parent component (ContentTagsDrawer) was being updated in the middle of a state update in (ContentTagsCollapsible). This seperated the two state updates to avoid this issue.
Whenever we get new applied tags from the backend, we reset the applied tags that are checked, and only check the explicit tags. This was causing an issue of duplicate applied tags being added to the selectbox.
603416c
to
94581f1
Compare
@xitij2000 Good catch! I fixed the issue here (234afac). It turns out I forgot to reset the "added" (checked) tags whenever we get the applied tags from the backend, so it would keep adding the remaining existing tags to the selectable box again everytime we delete one (react query would fetch latest tags). In older versions of the code, I would clear all of them, but now since we have staged tags, I only need to clear the applied ones, then only add the latest explicit ones. |
@yusuf-musleh 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR add the new "Add Tags" widget. Which separates out staging tags when checking them and committing (saving) them.
Supporting information
Related Tickets:
Testing instructions
Private-ref: FAL-3643