-
Notifications
You must be signed in to change notification settings - Fork 39
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
188286105 Drag from Plugins to Codap #1532
Conversation
codap-v3 Run #4737
Run Properties:
|
Project |
codap-v3
|
Branch Review |
main
|
Run status |
Passed #4737
|
Run duration | 01m 44s |
Commit |
20c21dcfb0: 188286105 Drag from Plugins to Codap (#1532)
|
Committer | Teale Fristoe |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
1
|
View all changes introduced in this branch ↗︎ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1532 +/- ##
===========================================
+ Coverage 54.69% 84.32% +29.63%
===========================================
Files 577 584 +7
Lines 29133 29521 +388
Branches 8013 8044 +31
===========================================
+ Hits 15935 24895 +8960
+ Misses 12417 4293 -8124
+ Partials 781 333 -448
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.
👍 Looks good -- just a few suggestions.
v3/src/hooks/use-drag-drop.ts
Outdated
@@ -29,6 +30,11 @@ export function getDragAttributeInfo(active: Active | null): Omit<IDragAttribute | |||
const { dataSet, attributeId } = active?.data.current as IDragAttributeData || {} | |||
return dataSet && attributeId ? { dataSet, attributeId } : undefined | |||
} | |||
export function getOverlayDragId(active: Active | null, instanceId: string, excludeIndexColumn = false) { |
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.
To keep this function (and this module) more generic, couldn't the last argument be excludeId
or excludeIds
and then clients could pass kIndexColumnKey
or [kIndexColumnKey]
so there's no explicit dependence on case tiles here? It could even be a regex so the client is responsible for knowing whether to match the beginning/end, etc.
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.
While I was working on converting this, I realized that CaseCard
probably doesn't need to exclude the index id, and that its original inclusion was likely a copy/paste artifact. Does that sound right to you? If so I'll just remove the exception from the component.
One other comment I forgot to mention in my earlier review -- it would make sense to have constants for the ids/classes referenced in the DI code so they're less likely to get out of sync: e.g. |
…d-consortium/codap into 188286105-v3-di-drag-drop
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.
👍 Changes look good! Just a couple minor suggestions.
PT Story: https://www.pivotaltracker.com/story/show/188286105
This work can be tested at: https://codap3.concord.org/branch/v3-di-drag-drop/#file=examples:Mammals
Using this version of Multidata: https://models-resources.concord.org/multidata-plugin/branch/drag-v3/index.html
This PR enables dragging attributes from plugins to Codap v3. In the past, this was accomplished using the HTML5 drag and drop system. However, Codap v3 uses
dnd-kit
for drag and drop, so the old system no longer works (and it never worked very well anyway, given security restrictions between iframes and their containers). Now, plugins enable drags within Codap by sending a series of API requests which trigger synthetic pointer events thatdnd-kit
reacts to.notify attribute
requests. Three requests must be made:dragStart
request will begin a drag by creating syntheticmousedown
andmousemove
events (because a drag won't actually begin until the mouse is moved at least three pixels).overlayHeight
andoverlayWidth
.dragOver
requests update the position of the drag overlay, and they should be continually requested as the user moves the mouse.mouseX
andmouseY
should be included in the request, and should be in the plugin's coordinate system.dragEnd
request will end the drag. It should also includemouseX
andmouseY
.PluginAttributeDrag
is a dummy element that is used as the basis of plugin initiated drags. It's a transparent div in theContainer
.AttributeDragOverlay
is also included in theContainer
, which follows the mouse during plugin initiated drags. Its size and position is controlled by API requests.PluginAttributeDrag
(dataSetId
andattributeId
) andAttributeDragOverlay
(overlay size and position) via newuiState
properties.Other changes in this PR:
getOverlayDragId
function is used to unify howAttributeDragOverlay
activeDragIds
are generated.fieldRequiredResult
function generates common error messages to API handlers.data-set-utils
that failed to broadcast a notification in certain situations when attributes were moved.