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 console error in quick-label-removal #4939

Merged
merged 4 commits into from
Oct 19, 2021

Conversation

cheap-glitch
Copy link
Contributor

Fixes #4934

Test URLs

refined-github/sandbox#3

Screenshot

n/a

Co-authored-by: Federico Brigante <[email protected]>
@cheap-glitch cheap-glitch marked this pull request as draft October 19, 2021 08:22
@cheap-glitch
Copy link
Contributor Author

Honestly I don't think this code is needed anymore. After doing some testing without it, it seems GitHub does update the labels dropdown correctly on its own (although it can take a second).

Maybe keep it for GHE?

@fregante
Copy link
Member

it seems GitHub does update the labels dropdown correctly on its own

Let's drop it if that's the case.

Maybe keep it for GHE?

Not a fundamental feature, so we can drop it

@cheap-glitch cheap-glitch marked this pull request as ready for review October 19, 2021 14:36
@cheap-glitch cheap-glitch merged commit fd1c82e into main Oct 19, 2021
@cheap-glitch cheap-glitch deleted the fix-quick-label-removal-error branch October 19, 2021 14:38
const menu = deferredContentWrapper.closest('[src]')!;
deferredContentWrapper.textContent = '';
deferredContentWrapper.append(<include-fragment src={menu.getAttribute('src')!}/>);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is still beneficial.

In #4953 I removed a label and then opened the menu to add one. The label was still selected in there and it added the label again.

Maybe a "simpler" or safer alternative would be to look for the specific label in the dropdown and disable it there as well, to avoid this specific issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that bug too.

The fix is tricky, because immediately replacing the dropdown content with an include fragment doesn't always work, especially when removing several labels in quick succession and then opening the dropdown right away.

Maybe we should add a listener on the dropdown button? The logic would be:

  1. When a label is removed, mark the dropdown as "outdated" but don't actually force it to update
  2. Listen to the opening of the dropdown. If it's outdated and GitHub hasn't already updated its contents (i.e. no include fragments is already there), replace them with an <include-fragment>.

Maybe a "simpler" or safer alternative would be to look for the specific label in the dropdown and disable it there as well, to avoid this specific issue

Changing the aria-selected attribute of a label in the dropdown has zero effect, it's purely cosmetic.

Copy link
Member

Choose a reason for hiding this comment

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

I don't remember how it works, but doesn't GitHub already use a "data-url" attribute that is then loaded as a fragment when the user clicks it? If it is, then we just need to set it again and empty the dropdown. GitHub will then take care of loading it as usual.

I don't want something super complicated though 😬 I think this would be good if it works

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

Successfully merging this pull request may close these issues.

quick-label-removal: deferredContentWrapper is undefined
2 participants