Skip to content

Improve reliability of clean-repo-tabs + more-dropdown-links - #5614

Merged
cheap-glitch merged 2 commits into
mainfrom
fix-repo-tabs-errors
May 6, 2022
Merged

cheap-glitch merged 2 commits into
mainfrom
fix-repo-tabs-errors

Conversation

@cheap-glitch

Copy link
Copy Markdown
Contributor

Fixes #5244 (hopefully)

Test URLs

Any repo page. The errors are more likely to appear when applying some throttling.

Screenshot

n/a

Comment on lines +34 to +47
function onlyShowInDropdown(id: string): void {
const tabItem = select(`[data-tab-item$="${id}"]`);
if (!tabItem && pageDetect.isEnterprise()) { // GHE #3962
return;
}

(tabItem!.closest('li') ?? tabItem!.closest('.UnderlineNav-item'))!.classList.add('d-none');

const menuItem = select(`[data-menu-item$="${id}"]`)!;
menuItem.removeAttribute('data-menu-item');
menuItem.hidden = false;
// The item has to be moved somewhere else because the overflow nav is order-dependent
select('.UnderlineNav-actions ul')!.append(menuItem);
}

@cheap-glitch cheap-glitch Apr 28, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved this function over since it's only ever used in this file.

Comment on lines -50 to +36
select('.js-responsive-underlinenav-overflow ul')!.append(
// Wait for the nav dropdown to be loaded #5244
const repoNavigationDropdown = await elementReady('.UnderlineNav-actions ul');
repoNavigationDropdown!.append(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can very reliably trigger an error on this select, and changing it to an elementReady fixes it.

@cheap-glitch
cheap-glitch marked this pull request as ready for review May 5, 2022 15:41
@cheap-glitch cheap-glitch changed the title Improve reliability of clean-repo-tabs and more-dropdown-links Improve reliability of clean-repo-tabs + more-dropdown-links May 6, 2022
@cheap-glitch
cheap-glitch merged commit 321f1b0 into main May 6, 2022
@cheap-glitch
cheap-glitch deleted the fix-repo-tabs-errors branch May 6, 2022 10:28
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.

clean-repo-tabs: undefined is not an object (evaluating 'tabItem.closest')

2 participants