Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
only synchronize clipboards if data was or is going to be sent (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaiah Becker-Mayer authored Mar 3, 2022
1 parent 5f8aef1 commit c49a241
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/teleport/src/DesktopSession/useTdpClientCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function useTdpClientCanvas(props: Props) {

// Default TdpClientEvent.TDP_CLIPBOARD_DATA handler.
const onClipboardData = (clipboardData: ClipboardData) => {
if (enableClipboardSharing && document.hasFocus()) {
if (enableClipboardSharing && document.hasFocus() && clipboardData.data) {
navigator.clipboard.writeText(clipboardData.data);
}
};
Expand Down Expand Up @@ -142,9 +142,11 @@ export default function useTdpClientCanvas(props: Props) {
// We must check that the DOM is focused or navigator.clipboard.readText throws an error.
if (enableClipboardSharing && document.hasFocus()) {
navigator.clipboard.readText().then(text => {
cli.sendClipboardData({
data: text,
});
if (text) {
cli.sendClipboardData({
data: text,
});
}
});
}
};
Expand Down

0 comments on commit c49a241

Please sign in to comment.