Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions src/content/github/file/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ async function main(): Promise<void> {
print("file not detected at current URL");
return;
}
if (!document.querySelector('[data-testid="raw-button"]')) {
print("Raw button not found – skipping coverage overlay (non-text file?)");
return;
}
globals.coverageButton = createCoverageButton();
await process(urlMetadata);
} catch (e) {
Expand Down Expand Up @@ -162,7 +166,9 @@ async function process(metadata: FileMetadata): Promise<void> {
previousElement: globals.coverageButton!,
selectedOptions: selectedFlags,
onClick: handleFlagClick,
}).then(({ button, list }) => {
}).then((result) => {
if (!result) return;
const { button, list } = result;
globals.flagsButton = button;
globals.flagsDrop = new Drop({
target: button,
Expand Down Expand Up @@ -201,7 +207,9 @@ async function process(metadata: FileMetadata): Promise<void> {
previousElement: globals.coverageButton!,
onClick: handleComponentClick,
selectedOptions: selectedComponents,
}).then(({ button, list }) => {
}).then((result) => {
if (!result) return;
const { button, list } = result;
globals.componentsButton = button;
globals.componentsDrop = new Drop({
target: button,
Expand Down
2 changes: 1 addition & 1 deletion src/content/github/file/utils/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function createDropdown({
}) {
const rawButton = document.querySelector('[data-testid="raw-button"]');
if (!rawButton) {
throw new Error("Raw button not found");
return null;
}
const dropdownButton = rawButton.cloneNode(true) as HTMLElement;
const textNode = dropdownButton.querySelector('[data-component="text"]');
Expand Down
Loading