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

Fix context menu handling to prioritize link URLs and include anchor text as bookmark titles #866

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 7 additions & 1 deletion apps/browser-extension/src/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ async function handleContextMenuClick(info: chrome.contextMenus.OnClickData) {
});
} else if (menuItemId === ADD_LINK_TO_HOARDER_ID) {
let newBookmark: ZNewBookmarkRequest | null = null;
if (info.selectionText) {
if (info.linkUrl) {
newBookmark = {
type: BookmarkTypes.LINK,
url: info.linkUrl,
title: info.selectionText ?? undefined,
};
} else if (info.selectionText) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm, the ordering of the ifs makes me think that having text selection taking higher priority was some intentional decision. I'll need to remember why it was done that way :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha. Take your time. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any update on this?

newBookmark = {
type: BookmarkTypes.TEXT,
text: info.selectionText,
Expand Down