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

SDA-4481: Add Fix to image cannot be copied #2109

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

NguyenTranHoangSym
Copy link
Contributor

Description

The fix targets to remove regression on cannot copy image of Workspace / Popout. This fix does not include pasting from workspace/popout to 3rd parties, currently tech limitation.

Related PRs

Demo

TinyTake.by.MangoApps-11-03-2024-04-56-25.mp4

@@ -376,12 +376,17 @@ export class ContextMenuBuilder {
* Adds "Copy Image" and "Copy Image URL" items when `src` is valid.
*/
public addImageItems(menu, menuInfo) {
const target = this.getWebContents();
const current = this.getWebContents();
Copy link
Contributor

@sbenmoussati sbenmoussati Mar 11, 2024

Choose a reason for hiding this comment

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

Suggested change
const current = this.getWebContents();
const focusedWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
if(focusedWindow && focusedWindow.winName !== apiName.mainWindowName) {
focusedWindow.webContents.send('copy-to-clipboard', menuInfo.srcURL);
} else {
focusedWindow.webContents.copyImageAt(menuInfo.x, menuInfo.y);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This way you ensure that window is the main window and not a child window

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest using focused window to check main,
remaining logic might not be different due to getWebcontent using exact same as BrowserWindow focus if current webcontent is not found

const copyImage = new MenuItem({
label: this.stringTable.copyImage(),
click: (_e) => {
if (focusedWindow && focusedWindow.winName === apiName.mainWindowName) {
current?.send('copy-to-clipboard', menuInfo.srcURL);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
current?.send('copy-to-clipboard', menuInfo.srcURL);
focusedWindow.webContents.send('copy-to-clipboard', menuInfo.srcURL);

@NguyenTranHoangSym NguyenTranHoangSym merged commit 668e68e into finos:main Apr 4, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants