Skip to content

extensible-nav - Allow extension by other features#9832

Merged
fregante merged 13 commits into
mainfrom
extensible-extension
Jul 15, 2026
Merged

extensible-nav - Allow extension by other features#9832
fregante merged 13 commits into
mainfrom
extensible-extension

Conversation

@fregante

@fregante fregante commented Jul 15, 2026

Copy link
Copy Markdown
Member

Comment on lines -4 to -9
.UnderlineNav-octicon {
@media (max-width: 1100px) {
/* Somewhat match the native behavior for now. `mobile-tabs` would be better */
display: none !important;
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This behavior has been somewhat intentionally dropped. Really not a fan of icon-less tabs. mobile-tabs and clean-repo-tabs will be better solutions

Comment on lines -71 to -74
// Final check to avoid duplicates in any scenario.
if (elementExists('.rgh-extensible-nav')) {
return;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I reckon Svelte's mount() should detect mounting on the same target and deduplicate/update it. Wish me luck

@fregante
fregante marked this pull request as ready for review July 15, 2026 13:01
Base automatically changed from enable-react-navigation to main July 15, 2026 15:57
$(`.rgh-extensible-nav a[href="${currentTab.href}"]`).classList.add('selected');
const currentTab = $('nav[aria-label="Repository"] a[aria-current][data-tab-item]');
const itemId = currentTab.getAttribute('data-tab-item')!;
selectTab(itemId);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The marvels of DOM soup manipulation

init: onetime(initOnce),
}, {
asLongAs: [
() => isReady,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No need to wait anymore. The stores are available immediately and any changes will be stored until needed.

Comment on lines -71 to -72
// Final check to avoid duplicates in any scenario.
if (elementExists('.rgh-extensible-nav')) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Once again hoping Svelte figures this out autonomously of mounted twice on the same element (however it's still not as safe)

Comment on lines +14 to +48
const nativeTabs = writable<Tab[]>([]);
const extraTabs = writable<ExtraTab[]>([]);
const hiddenIds = writable(new Set<string>());

export const selectedId = writable<string | undefined>();

export const tabs = derived(
[nativeTabs, extraTabs, hiddenIds],
([$nativeTabs, $extraTabs, $hiddenIds]) => {
const tabs = $nativeTabs.filter(({id}) => !$hiddenIds.has(id));

for (const {tab, before} of $extraTabs) {
const index = before ? tabs.findIndex(({id}) => id === before) : -1;
tabs.splice(index === -1 ? tabs.length : index, 0, tab);
}

return tabs;
},
);

export function setNativeTabs(nativeTabsList: Tab[]): void {
nativeTabs.set(nativeTabsList);
}

export function addTab(tab: Tab, before?: string): void {
extraTabs.update(current => [...current, {tab, before}]);
}

export function hideTab(id: string): void {
hiddenIds.update(current => new Set(current).add(id));
}

export function selectTab(id: string): void {
selectedId.set(id);
}

@fregante fregante Jul 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the ugly part. This isn't final, we'll have to add capabilities as required. For example there's still no way to update a counter (e.g. for bugs-tab)

@fregante

Copy link
Copy Markdown
Member Author

:)

Screenshot 5

We're not there yet, but the tab can now be added via:

import BugIcon from 'octicons-plain-react/Bug';

addTab({
	id: 'bugs',
	href: '/bugs',
	label: 'Bugs',
	icon: BugIcon,
}, 'pull-requests');

@fregante
fregante enabled auto-merge (squash) July 15, 2026 17:41
@fregante
fregante merged commit 128a26d into main Jul 15, 2026
19 checks passed
@fregante fregante mentioned this pull request Jul 15, 2026
13 tasks
@fregante
fregante deleted the extensible-extension branch July 15, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant