Skip to content
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

[DYN-6361] Bugfix copy/paste operation conflict between library search and Workspace #14998

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ internal void RefreshLibraryView(WebView2 browser)
/// <param name="text">text to be added to clipboard</param>
internal void OnCopyToClipboard(string text)
{
dynamoViewModel.Model.ClipBoard.Clear();
Clipboard.Clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to clear both clipboard?

Copy link
Contributor Author

@Enzo707 Enzo707 Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to remove that statement, I've just update the PR.
However I'm going to set the PR as a draft as I realized there's an use case that need to be addressed before wrap this up. If you perform a node paste into workspace, then copy anything from outside Dynamo and paste it into library search it will paste the node as well, as it remains on clipboard.

Copy link
Contributor

@RobertGlobant20 RobertGlobant20 Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Enzo707 this is the approach that I was talking about when implemeting the functionality of copying an external text to Dynamo, then you need to do the next steps to reproduce the bug:

  1. Add a Number node in workspace
  2. Select the Number node and press Ctrl + C
  3. Then press Ctrl + V (the node will be added/copied in workspace)
  4. The go to an external app (like notepad), select a text and press Ctrl + C
  5. Return to Dynamo, go to the Search TextBox in Library and press Ctrl + V
    The problem is that is copying the text from Notepad to the Search TextBox in Library and also adding/copying a Number node in workspace.

Then for fixing this problem my approach was to add a variable that holds the focused element, in this case when the SearchTextBox is focused or lost focus a value will be set in the variable.
I've already tested and seems that is working as expected, please double check.

This are the lines used for subcribing to the focus event and lost focus event(I executed it using the DeveloperTools), probably needs to be added in React when the page is already loaded because when I added it to library.html was crashing the webpage.

document.getElementsByClassName("SearchInputText")[0].addEventListener("focusin", (event) => {
window.chrome.webview.postMessage(JSON.stringify({ "func": "FocusUpdated", "data": "Focused" }));
});

document.getElementsByClassName("SearchInputText")[0].addEventListener("focusout", (event) => {
window.chrome.webview.postMessage(JSON.stringify({ "func": "FocusUpdated", "data": "LostFocus" }));
});

This is the branch in which I uploaded the code (the last commit has the updated code):
https://github.com/RobertGlobant20/Dynamo/tree/DYN-6361-CopyPaste-FixProposal

Clipboard.SetText(text);
}

Expand Down
Loading