Skip to content

Change Dropdowns to use Radix's DropdownMenu #3189

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/twelve-beers-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gitbook": patch
---

Change `Dropdown`s to use Radix's `DropdownMenu`
113 changes: 112 additions & 1 deletion bun.lock

Large diffs are not rendered by default.

45 changes: 28 additions & 17 deletions packages/gitbook/e2e/internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,24 @@ const testCases: TestsCase[] = [
name: 'Customized variant titles are displayed',
url: '',
run: async (page) => {
const spaceDrowpdown = page
const spaceDropdown = page
.locator('[data-testid="space-dropdown-button"]')
.locator('visible=true');
await spaceDrowpdown.click();
await spaceDropdown.click();

const variantSelectionDropdown = page.locator(
'css=[data-testid="space-dropdown-button"] + div'
'css=[data-testid="dropdown-menu"]'
);
// the customized space title
await expect(
variantSelectionDropdown.getByRole('link', {
variantSelectionDropdown.getByRole('menuitem', {
name: 'Multi-Variants',
})
).toBeVisible();

// the NON-customized space title
await expect(
variantSelectionDropdown.getByRole('link', {
variantSelectionDropdown.getByRole('menuitem', {
name: 'RFCs',
})
).toBeVisible();
Expand All @@ -145,14 +145,17 @@ const testCases: TestsCase[] = [
url: 'api-multi-versions/reference/api-reference/pets',
screenshot: false,
run: async (page) => {
const spaceDrowpdown = await page
const spaceDropdown = await page
.locator('[data-testid="space-dropdown-button"]')
.locator('visible=true');
await spaceDrowpdown.click();
await spaceDropdown.click();

const variantSelectionDropdown = page.locator(
'css=[data-testid="dropdown-menu"]'
);
// Click the second variant in the dropdown
await page
.getByRole('link', {
await variantSelectionDropdown
.getByRole('menuitem', {
name: '2.0',
})
.click();
Expand All @@ -168,14 +171,18 @@ const testCases: TestsCase[] = [
url: 'api-multi-versions-share-links/8tNo6MeXg7CkFMzSSz81/reference/api-reference/pets',
screenshot: false,
run: async (page) => {
const spaceDrowpdown = await page
const spaceDropdown = await page
.locator('[data-testid="space-dropdown-button"]')
.locator('visible=true');
await spaceDrowpdown.click();
await spaceDropdown.click();

const variantSelectionDropdown = page.locator(
'css=[data-testid="dropdown-menu"]'
);

// Click the second variant in the dropdown
await page
.getByRole('link', {
await variantSelectionDropdown
.getByRole('menuitem', {
name: '2.0',
})
.click();
Expand Down Expand Up @@ -205,14 +212,18 @@ const testCases: TestsCase[] = [
return `api-multi-versions-va/reference/api-reference/pets?jwt_token=${token}`;
},
run: async (page) => {
const spaceDrowpdown = await page
const spaceDropdown = await page
.locator('[data-testid="space-dropdown-button"]')
.locator('visible=true');
await spaceDrowpdown.click();
await spaceDropdown.click();

const variantSelectionDropdown = page.locator(
'css=[data-testid="dropdown-menu"]'
);

// Click the second variant in the dropdown
await page
.getByRole('link', {
await variantSelectionDropdown
.getByRole('menuitem', {
name: '2.0',
})
.click();
Expand Down
5 changes: 3 additions & 2 deletions packages/gitbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@gitbook/react-math": "workspace:*",
"@gitbook/react-openapi": "workspace:*",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.1.12",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-tooltip": "^1.1.8",
Expand All @@ -37,6 +38,7 @@
"assert-never": "^1.2.1",
"bun-types": "^1.1.20",
"classnames": "^2.5.1",
"event-iterator": "^2.0.0",
"framer-motion": "^10.16.14",
"js-cookie": "^3.0.5",
"jsontoxml": "^1.0.1",
Expand All @@ -52,6 +54,7 @@
"openapi-types": "^12.1.3",
"p-map": "^7.0.0",
"parse-cache-control": "^1.0.1",
"partial-json": "^0.1.7",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hotkeys-hook": "^4.4.1",
Expand All @@ -70,8 +73,6 @@
"usehooks-ts": "^3.1.0",
"zod": "^3.24.2",
"zod-to-json-schema": "^3.24.5",
"event-iterator": "^2.0.0",
"partial-json": "^0.1.7",
"zustand": "^5.0.3"
},
"devDependencies": {
Expand Down
143 changes: 0 additions & 143 deletions packages/gitbook/src/components/Header/Dropdown.tsx

This file was deleted.

Loading
Loading