-
Notifications
You must be signed in to change notification settings - Fork 95
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
1.18 ports8 #7233
1.18 ports8 #7233
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useCallback, useMemo } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useSelectionActions } from "../components/graph/SelectionContextProvider"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { EventTrackingSelector, EventTrackingType, TrackEventParams, useEventTracking } from "./event-tracking"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useDocumentListeners } from "./useDocumentListeners"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { EventTrackingSelector, TrackEventParams, EventTrackingType, useEventTracking } from "./event-tracking"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const isInputTarget = (target: EventTarget): boolean => ["INPUT", "SELECT", "TEXTAREA"].includes(target?.["tagName"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const isInputEvent = (event: Event): boolean => isInputTarget(event?.target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -46,12 +46,17 @@ export function BindKeyboardShortcuts({ disabled }: { disabled?: boolean }): JSX | |||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isInputEvent(event) || !keyHandler) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
return keyHandler(event); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
copy: (event) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.copy ? eventWithStatistics({ selector: EventTrackingSelector.CopyNode }, userActions.copy(event)) : null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
paste: (event) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.paste ? eventWithStatistics({ selector: EventTrackingSelector.PasteNode }, userActions.paste(event)) : null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
cut: (event) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.cut ? eventWithStatistics({ selector: EventTrackingSelector.CutNode }, userActions.cut(event)) : null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
copy: (event) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isInputEvent(event)) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.copy ? eventWithStatistics({ selector: EventTrackingSelector.CopyNode }, userActions.copy(event)) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
paste: (event) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.paste ? eventWithStatistics({ selector: EventTrackingSelector.PasteNode }, userActions.paste(event)) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
cut: (event) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isInputEvent(event)) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
userActions.cut ? eventWithStatistics({ selector: EventTrackingSelector.CutNode }, userActions.cut(event)) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+49
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Several improvements needed in clipboard event handlers
Here's a suggested improvement: copy: (event) => {
if (isInputEvent(event)) return;
- userActions.copy ? eventWithStatistics({ selector: EventTrackingSelector.CopyNode }, userActions.copy(event)) : null;
+ event.preventDefault();
+ userActions.copy?.(event) && eventWithStatistics({ selector: EventTrackingSelector.CopyNode }, true);
},
paste: (event) => {
+ if (isInputEvent(event)) return;
- userActions.paste ? eventWithStatistics({ selector: EventTrackingSelector.PasteNode }, userActions.paste(event)) : null;
+ event.preventDefault();
+ userActions.paste?.(event) && eventWithStatistics({ selector: EventTrackingSelector.PasteNode }, true);
},
cut: (event) => {
if (isInputEvent(event)) return;
- userActions.cut ? eventWithStatistics({ selector: EventTrackingSelector.CutNode }, userActions.cut(event)) : null;
+ event.preventDefault();
+ userActions.cut?.(event) && eventWithStatistics({ selector: EventTrackingSelector.CutNode }, true);
}, This refactor:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
[eventWithStatistics, keyHandlers, userActions], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`GraphUtils prepareNewNodesWithLayout should update union output expression parameter with an updated node name when new unique node ids created 1`] = ` | ||
{ | ||
"idMapping": { | ||
"union": "union (copy 1)", | ||
"variable 1": "variable 1 (copy 1)", | ||
"variable 2": "variable 2 (copy 1)", | ||
}, | ||
"layout": [ | ||
{ | ||
"id": "variable 1 (copy 1)", | ||
"position": { | ||
"x": 350, | ||
"y": 859, | ||
}, | ||
}, | ||
{ | ||
"id": "variable 2 (copy 1)", | ||
"position": { | ||
"x": 710, | ||
"y": 859, | ||
}, | ||
}, | ||
{ | ||
"id": "union (copy 1)", | ||
"position": { | ||
"x": 530, | ||
"y": 1039, | ||
}, | ||
}, | ||
], | ||
"nodes": [ | ||
{ | ||
"additionalFields": { | ||
"description": null, | ||
"layoutData": { | ||
"x": 0, | ||
"y": 720, | ||
}, | ||
}, | ||
"branchParameters": undefined, | ||
"id": "variable 1 (copy 1)", | ||
"type": "Variable", | ||
"value": { | ||
"expression": "'value'", | ||
"language": "spel", | ||
}, | ||
"varName": "varName1", | ||
}, | ||
{ | ||
"additionalFields": { | ||
"description": null, | ||
"layoutData": { | ||
"x": 360, | ||
"y": 720, | ||
}, | ||
}, | ||
"branchParameters": undefined, | ||
"id": "variable 2 (copy 1)", | ||
"type": "Variable", | ||
"value": { | ||
"expression": "'value'", | ||
"language": "spel", | ||
}, | ||
"varName": "varName2", | ||
}, | ||
{ | ||
"additionalFields": { | ||
"description": null, | ||
"layoutData": { | ||
"x": 180, | ||
"y": 900, | ||
}, | ||
}, | ||
"branchParameters": [ | ||
{ | ||
"branchId": "variable 1 (copy 1)", | ||
"parameters": [ | ||
{ | ||
"expression": { | ||
"expression": "1", | ||
"language": "spel", | ||
}, | ||
"name": "Output expression", | ||
}, | ||
], | ||
}, | ||
{ | ||
"branchId": "variable 2 (copy 1)", | ||
"parameters": [ | ||
{ | ||
"expression": { | ||
"expression": "2", | ||
"language": "spel", | ||
}, | ||
"name": "Output expression", | ||
}, | ||
], | ||
}, | ||
], | ||
"id": "union (copy 1)", | ||
"nodeType": "union", | ||
"outputVar": "outputVar", | ||
"parameters": [], | ||
"type": "Join", | ||
}, | ||
], | ||
} | ||
`; |
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.
💡 Codebase verification
Add browser compatibility tests for clipboard functionality
The implementation has proper feature detection and fallback handling, but there are no dedicated tests found for the clipboard functionality. While the code structure is sound, consider:
🔗 Analysis chain
Verify browser compatibility testing
The implementation looks good with proper feature detection and fallback handling. However, ensure that browser compatibility testing is in place.
Let me check the babel configuration to understand the browser compatibility settings.
Let me check for any browser compatibility configurations in package.json as browserslist is commonly defined there.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 153
Script:
Length of output: 1667
Script:
Length of output: 129