Skip to content

Conversation

@arctan95
Copy link

@arctan95 arctan95 commented Apr 9, 2025

Description

Fix mouseleave event triggered when clicking on the canvas

Resolved issues

Closes #5

@arctan95 arctan95 changed the title fix: refocuse canvas to pick up keystrokes fix: refocus canvas to pick up keystrokes Apr 9, 2025
Copy link

@ishita1805 ishita1805 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Owner

@roerohan roerohan left a comment

Choose a reason for hiding this comment

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

I've requested a small change, also let me know if you've tested it.

Does the same issue happen when you use noVNC (upstream) directly? Honestly, I've never been able to reproduce it 😓

};

const refocusCanvasOnCaptureElem = () => {
const canvas = document.querySelector('canvas');
Copy link
Owner

Choose a reason for hiding this comment

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

If there's another canvas on the page before the noVNC canvas, this line will select that won't it?

Maybe we could do something like

const canvases = Array.from(document.querySelectorAll('canvas'));
const canvas = canvases.filter(({ id }) => id === 'noVNC_mouse_capture_elem');

By the way, have you tested this approach? It does feel a little hacky, but since a lot of people have been facing it I'm happy to merge it (provided it doesn't break anything of course 😅)

@arctan95
Copy link
Author

I've requested a small change, also let me know if you've tested it.

Does the same issue happen when you use noVNC (upstream) directly? Honestly, I've never been able to reproduce it 😓

Yes, this issue does exist upstream. The current approach is a little hacky indeed, hope the upstream will fix it soon.

@arctan95 arctan95 closed this by deleting the head repository May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MouseLeave event triggered when clicking on the canvas embedded in the VncScreen component

3 participants