Skip to content

Commit

Permalink
fix: Focus to document before copying URL and title
Browse files Browse the repository at this point in the history
Fixes #58

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/nandenjin/tsukimi/issues/58?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
nandenjin committed Dec 12, 2024
1 parent a18a3fb commit 52f2735
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/background/features/copyUrlAndTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
const url = getPageURL()
const title = getPageTitle()

// Check if the document has focus
if (!document.hasFocus()) {
// Attempt to focus the document
window.focus()
document.body.focus()
}

// Copy URL and Title
navigator.clipboard.writeText(`[${title} ${url}]`)
console.log('Copied URL and Title')
Expand Down

0 comments on commit 52f2735

Please sign in to comment.