Skip to content

clean-conversation-sidebar wrongly hides projects #5757

Closed

Description

@akien-mga

Please ensure:

  • The bug is caused by Refined GitHub. It doesn't happen if I disable the extension.
  • The bug happens after clearing extension cache. The "Clear cache" button below can also be found at the bottom of the options page.

Example URLs

godotengine/godot#62552

Extension version

22.6.25

Browser(s) used

Firefox Nightly 104

Description

Refined GitHub is wrongly hiding projects assigned to issues which are using the older GitHub Project format (now renamed to "Projects (classic)" and I suspect that's what broke RG's logic for it).

Here's how it looks without RG:

image

And with RG, video of refreshing the page (don't mind the lock symbol, I made it public afterwards):

simplescreenrecorder-2022-06-30_13.49.43.mp4

Include in this issue:

  • Screenshots/video/gif demonstrating the bug, if it’s visual
  • Console errors, if any

Activity

  1. akien-mga commented on Jun 30, 2022

    @akien-mga
    Author

    Actually it's also failing with "Projects (beta)" links, e.g. here: godotengine/godot-proposals#4548

    Without RG:

    image

    With RG:

    image

  2. changed the title [-]GitHub "Projects (classic)" are wrongly hidden from the issue toolbar[/-] [+]GitHub Projects are wrongly hidden from the issue toolbar[/+] on Jun 30, 2022
  3. Wenderson-P commented on Jun 30, 2022

    @Wenderson-P

    The Projects reappeared after I turned off the clean-conversation-sidebar setting

  4. changed the title [-]GitHub Projects are wrongly hidden from the issue toolbar[/-] [+]`clean-conversation-sidebar` wrongly hides projects[/+] on Jun 30, 2022
  5. iamziike commented on Jul 2, 2022

    @iamziike
    Contributor

    The problem lies here

    if (heading.nextElementSibling?.firstElementChild) {
    return false;
    }

    The heading.nextElementSibling?.firstElementChild is null when passed a selector here

    cleanSection('[aria-label="Select milestones"]');

    I thought about a solution where I pass the number of "steps" to take get the firstElementChild
    steps =1 ===> heading.nextElementSibling?.firstElementChild
    steps =2 ===> heading.nextElementSibling?.nextElementSibling?.firstElementChild

    function cleanSection(selector: string, step:number = 1): boolean {
    	const container = select(selector)?.closest('form, .discussion-sidebar-item');
    	if (!container) {
    		return false;
    	}
    
    	const heading = select(':scope > details, :scope > .discussion-sidebar-heading', container)!;
    
    	// Magic. Do not touch.
    	// Section is empty if: no sibling element OR empty sibling element
    	if (step === 1 &&  heading.nextElementSibling?.firstElementChild) {
    		return false;
    	}
    
    	if (step === 2 &&  heading.nextElementSibling?.nextElementSibling?.firstElementChild) {
    		return false;
    	}
    
    	const section = container.closest('.discussion-sidebar-item')!;
    	if (canEditSidebar()) {
    		getNodesAfter(heading).deleteContents();
    		section.classList.add('rgh-clean-sidebar');
    	} else {
    		section.remove();
    	}
    
    	return true;
    }

    Ps. I was going for a solution where I did not have to change a bunch so WDYT?

  6. fregante commented on Jul 2, 2022

    @fregante
    Member

    how dare you touch it 😰 😜

    The magic broke and now heading.nextElementSibling points to a new intermediate element:

    Screen Shot 2

    I think we should just replace the line with something more specific that covers every scenario (milestones, projects, linked issues):

    if (!heading.closest('form').querySelector('icon, progress, etc')) {
    	return false
    }

    'icon, progress, etc' would be a selector for elements that appear only if these sections are full. It's probably .Progress, .octicon-table, [data-hovercard-type] but it needs testing to ensure it doesn't match elements inside the dropdown/selector

  7. iamziike commented on Jul 2, 2022

    @iamziike
    Contributor

    @fregante ok, I'll like to work on it but to clarify we are ditching the "Magic" right

  8. fregante commented on Jul 2, 2022

    @fregante
    Member

    Correct. The piece of code I suggested replaces the magic condition

  9. added a commit that references this issue on Jul 4, 2022
    ee3926d
  10. fregante commented on Jul 7, 2022

    @fregante
    Member

    Oof, can’t wait to turn this feature into a CSS-based feature thanks to the :has() selector. So many possibilities!

  11. added a commit that references this issue on Jul 12, 2022
  12. matschaffer commented on Jul 21, 2022

    @matschaffer

    thanks @fregante ! Seems to be working great

  13. fregante commented on Jul 21, 2022

    @fregante
    Member

    Thank @iamziike 🎉

  14. matschaffer commented on Jul 21, 2022

    @matschaffer

    Indeed! Thank you @iamziike and apologies - I thought the issue "closed" timeline would have mentioned the PR author. Guess not 😊

    Great to have it fixed and back to using Refined Github!

  15. marcphilipp commented on Jul 21, 2022

    @marcphilipp

    It seems this is still disabled (in Firefox) with 22.7.20, isn't it?

    image

  16. fregante commented on Jul 21, 2022

    @fregante
    Member

    It was disabled via YOLO. Clear your cache (options page) to see it work again

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions