Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/e2e/code-tabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ test('a tab shows its file, with focus on its tab, and the copy button copies it
await expect.poll(() => clipboard(page)).toContain('import sys');
});

test('the block stays in place when the tab changes', async ({ page }) => {
await load(page);
const top = () => visible(page, 0).evaluate((block) => block.getBoundingClientRect().top + window.scrollY);
const first = await top();
for (const name of ['greet.py', 'greet.js']) {
await visible(page, 0).getByRole('tab', { name }).click();
expect(await top()).toBe(first);
}
});

test('label tabs have no icon, and synced blocks switch together and remember the choice', async ({ page }) => {
await load(page);
await expect(visible(page, 1).getByRole('tab')).toHaveText(['npm', 'pnpm', 'Yarn']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function pluginCodeTabs(fileIcons?: Partial<FileIconSettings>): Codeblock
return {
name: 'starlight-codeblocks:code-tabs',
baseStyles: ({ cssVar }) => `
/* Starlight spaces each block after a sibling, even a hidden one, so the block would move when the tab changes. */
[data-scb-code-tabs] > & { margin-top: 0; }
.${FIELD} {
position: relative;
display: inline-flex;
Expand Down
Loading