-
Notifications
You must be signed in to change notification settings - Fork 85
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: Change behaviour of Tag Drawer on click outside #965
[FC-0036] feat: Change behaviour of Tag Drawer on click outside #965
Conversation
Thanks for the pull request, @ChrisChV! 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. |
d36bf33
to
73c978b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #965 +/- ##
==========================================
+ Coverage 92.06% 92.08% +0.01%
==========================================
Files 685 686 +1
Lines 12054 12075 +21
Branches 2626 2631 +5
==========================================
+ Hits 11098 11119 +21
Misses 920 920
Partials 36 36 ☔ View full report in Codecov by Sentry. |
9004ea8
to
30f19c7
Compare
* Avoid close Tags drawer on edit * To avoid lose user data * Wrap with ContentTagsDrawerSheet to build drawer on MFE * ContentTagsDrawerSheetContext created * Not close drawer with Escape is pressed when container is blocked
30f19c7
to
9bfe994
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.
For me, this just isn't working. I can edit the tags, but escape is still working.
Additionally, I don't see any code to prevent it from closing when clicking outside.
I think this can be simplified a lot. I've given example code that I tested, and it's working. All the context is already available there.
/* istanbul ignore next */ | ||
export const ContentTagsDrawerSheetContext = React.createContext({ | ||
blockingSheet: /** @type{boolean} */ (false), | ||
setBlockingSheet: /** @type{Function} */ (() => {}), | ||
}); |
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.
Is there any reason to add another context instead of using the same one?
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.
Additionally, it seems like the value of 'blockingSheet' is just derived from whether tags have been added or not, an actual count is not important.
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 have added one more layer above, currently it is like this: ContentTagsDrawerSheet > ContentTagsDrawer > ContentTagsCollapsible
. The drawer is used in:
frontend-app-course-authoring
UI: HereContentTagsDrawerSheet
is used.edx-platform
UI as iframe: HereContentTagsDrawer
is used, notContentTagsDrawerSheet
.
I have separated it because ContentTagsDrawerSheetContext
is ContentTagsDrawerSheet
logic and is not used in the legacy edx-platform
screens. This will change in the future, so I'm going to add comments in the code
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.
Additionally, it seems like the value of 'blockingSheet' is just derived from whether tags have been added or not, an actual count is not important.
Updated here: 1fe6282
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 have separated it because ContentTagsDrawerSheetContext is ContentTagsDrawerSheet logic and is not used in the legacy edx-platform screens. This will change in the future, so I'm going to add comments in the code
Comments added here: cf746b4
@@ -64,7 +65,7 @@ const ContentTagsDrawer = ({ id, onClose }) => { | |||
const handleEsc = (event) => { | |||
/* Close drawer when ESC-key is pressed and selectable dropdown box not open */ | |||
const selectableBoxOpen = document.querySelector('[data-selectable-box="taxonomy-tags"]'); | |||
if (event.key === 'Escape' && !selectableBoxOpen) { | |||
if (event.key === 'Escape' && !selectableBoxOpen && !blockingSheet) { |
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 think it's simpler to do this instead:
const blockingSheet = (Object.keys(globalStagedContentTags).length + Object.keys(globalStagedRemovedContentTags).length) > 0;
There doesn't seem to be any need to add another context, and state variable for something that can already be derived from existing info.
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 think it is better to leave it as context since it is used in two different places:
- To avoid close on click outside: https://github.com/openedx/frontend-app-course-authoring/pull/965/files#diff-44e5b0a241ffd4d6230ede25608e5392858869b1b6761b64f1daac7c18605ff2R21
- To avoid close on press Escape: https://github.com/openedx/frontend-app-course-authoring/pull/965/files#diff-8f2b1f4e041cee96dfc16c4c3da7631943407c989c2ea619594681f0c40e775bR68
I prefer it this way, because in the first case it is not possible to calculate it there, and it is better to calculate that value in one place.
I think it's simpler to do this instead:
const blockingSheet = (Object.keys(globalStagedContentTags).length + Object.keys(globalStagedRemovedContentTags).length) > 0;
Furthermore, it could not be calculated in this way, because there is a case in which there are keys in the map, but they contain empty lists (add a tag, and remove the same tag later).
This functionality exists in paragon's Sheet component. I have added it there using
I think it is a confusion, the requirement is: https://www.loom.com/share/c87289b025b34b9ab2381a749dd9db4f?sid=fffede42-3e4d-4cf9-9dae-c0a72a7c2397 |
@xitij2000 It's ready for another review |
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.
OK. I think the issue I had was that I was testing with the old studio, however this seems to be implemented only for the new UI?
If this is supposed to work on the current studio as well, then this needs to be fixed. Otherwise I can merge.
I think it would take more time (ref). But, what do you think @bradenmacdonald? I can do it in another PR |
I'll ask about it. But in the meantime, please merge this, and if we need to implement it in the legacy UI, we'll do it in another PR. |
@ChrisChV 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
I played merge monkey on this one since this already had @xitij2000's approval, but he's out sick. |
Description
https://www.loom.com/share/c87289b025b34b9ab2381a749dd9db4f?sid=fffede42-3e4d-4cf9-9dae-c0a72a7c2397
Supporting information
Testing instructions
make requirements
on cms shell.Edit tags
Edit tags