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

GitHub Issue Add Details - no longer works #161

Open
darkred opened this issue Oct 24, 2021 · 3 comments
Open

GitHub Issue Add Details - no longer works #161

darkred opened this issue Oct 24, 2021 · 3 comments

Comments

@darkred
Copy link
Collaborator

darkred commented Oct 24, 2021

The 'GitHub Issue Add Details ' script no longer works (in existing or new comments of issue/pull requests).
Instead it shows in Console this error:

TypeError: Cannot read properties of null (reading 'parentNode')

referring to line 44:

btn.parentNode.insertBefore(button.cloneNode(true), btn.nextSibling);

Tested in a fresh Chrome profile witn only TM/VM installed.

@Mottie Mottie added the bug label Oct 24, 2021
@Mottie
Copy link
Owner

Mottie commented Oct 24, 2021

Thanks @darkred!

I keep meaning to update the code, but have been overly busy :(

Try this change:

  // Add insert details button
	function addDetailsButton() {
		const button = document.createElement("button");
		button.type = "button";
		button.className = "ghad-details toolbar-item tooltipped tooltipped-n";
		button.setAttribute("aria-label", "Add a details/summary block");
		button.setAttribute("tabindex", "-1");
		button.innerHTML = icon;
		[...document.querySelectorAll(".toolbar-commenting")].forEach(el => {
			if (el && !$(".ghad-details", el)) {
				const btn = $("[aria-label*='Add a task list']", el);
				btn.before(button.cloneNode(true));
			}
		});
	}

@darkred
Copy link
Collaborator Author

darkred commented Oct 24, 2021

Thank you for your quick response!

I tested it and it works ok in New Issue/PR forms and in existing Issues/PRs | New Comment form

If you would be so kind, when you have the chance, could you make it also work when editing existing comments in issues/PRs, please?

@Mottie
Copy link
Owner

Mottie commented Nov 30, 2021

I finally got around to updating the userscript, but I didn't add the enhancement you requested... once I find some more free time! 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants