Skip to content

Commit

Permalink
TBX-13272: maintain the correct order of highlighted line menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
maximmig committed Dec 1, 2024
1 parent 1942e4a commit 3fc4a19
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions providers/github/utils/observeBlobPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ export const observeBlobPage = (metadata, tools) => {
);

highlightedLineMenuObserver.start((highlightedLineMenu) => {
const lastButOneMenuItem = highlightedLineMenu.lastElementChild.previousElementSibling;
const viewFileInDifferentBranchMenuItem = highlightedLineMenu.lastElementChild;
const viewFileInGitHubDevMenuItem = viewFileInDifferentBranchMenuItem.previousElementSibling;
const targetMenuItem =
// The text is "View file in GitHub.dev" if user is authenticated, otherwise the text is "View git blame"
viewFileInGitHubDevMenuItem.textContent.trim() === "View file in GitHub.dev"
? viewFileInGitHubDevMenuItem
: viewFileInDifferentBranchMenuItem;
const highlightedLineMenuItems = createHighlightedLineMenuItems(metadata, tools);
highlightedLineMenuItems.forEach((highlightedLineMenuItem) => {
lastButOneMenuItem.insertAdjacentElement("beforebegin", highlightedLineMenuItem);
targetMenuItem.insertAdjacentElement("beforebegin", highlightedLineMenuItem);
});
});
};
Expand Down

0 comments on commit 3fc4a19

Please sign in to comment.