Skip to content

Reach menu button -> Radix - #1395

Merged
david-crespo merged 16 commits into
mainfrom
radix-menu
Mar 14, 2023
Merged

david-crespo merged 16 commits into
mainfrom
radix-menu

Conversation

@david-crespo

@david-crespo david-crespo commented Mar 11, 2023 •

Copy link
Copy Markdown
Collaborator

The difficulty on this one seems to be mostly in the styling. We were relying a bit on Reach's built in stylesheet. One difference in Radix that makes things harder is that the components don't come by default with any identifier on them like a class or a data attribute that lets you style them (turns out this is not quite true but they don't seem super specific — better to use the classes anyway). You have to explicitly put a class on them. Most likely I will make a UI component that does that so we don't have to remember, just like with tabs.

https://www.radix-ui.com/docs/primitives/components/dropdown-menu

This adds another 20kb to the bundle. Kinda disappointing! Net line changes excluding lockfile are 157 insertions(+), 121 deletions(-). Adds accounted for by DropdownMenu.tsx and some extra CSS pulled from Reach (which we can probably clean up).

To do

  • Convert everything and get rid of Reach
  • Incorporate Reach styles into classes, get rid of data attrs
  • Fix tooltip on disabled menu item
  • Make menu slightly less wide to match previous behavior
  • Get rid of focus ring on clicking out of a menu

@vercel

vercel Bot commented Mar 11, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 14, 2023 at 7:47PM (UTC)

Comment thread app/components/TopBar.tsx
aria-label="User menu"
className="ml-2"
innerClassName="space-x-2"
title="User menu"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not sure what this was doing or if it's necessary to find a new spot for it

# Conflicts:
#	app/components/TopBarPicker.tsx
#	package-lock.json
#	package.json
@david-crespo
david-crespo marked this pull request as ready for review March 14, 2023 17:51
@david-crespo

Copy link
Copy Markdown
Collaborator Author

Only issue remaining that I can find is this stupid focus ring.

2023-03-14-radix-menu-focus-bug

Content: ({ className, ...props }: DropdownMenuContentProps) => (
<Content
// prevents focus ring showing up on trigger when you close the menu
onCloseAutoFocus={(e) => e.preventDefault()}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@zephraph I don't see anything in the menu button pattern or examples insisting that focus land on the button after clicking out. However this also seems to break focus returning to the button if you click it to close the menu, which seems wrong? Unsure what to do, but probably not a blocker.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Focus going back to the button would be nice, but I don't think it's necessary. Depends on what the tab stack looks like at that point. If you close it and press tab or shift+tab does it go back to the button?

We can make a follow up, but I agree that it's not a blocker.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't go back to the button, it seems to reset back to the top level of the page. When I remove out the preventDefault and get the default behavior back, it does work the way you want: focus is on the button, and tabbing starts from there. The problem is really just the focus ring. I'll make an issue to think about this more.

@david-crespo
david-crespo enabled auto-merge (squash) March 14, 2023 19:47
@david-crespo
david-crespo merged commit 05e900b into main Mar 14, 2023
@david-crespo
david-crespo deleted the radix-menu branch March 14, 2023 19:52
david-crespo added a commit that referenced this pull request Nov 11, 2026
Nothing in the repo references these packages any more. The lockfile
goes from 709 to 704 entries. `tslib` and `@react-router/node` stay
installed as dependencies of other packages, so for those two this only
tidies `package.json`. Lint, tsc, build, and the vitest suite pass. I
did not run e2e locally.

- `tslib` came from the Nx generator that created the repo
([source](https://github.com/nrwl/nx/blob/313552b/packages/react/src/schematics/init/init.ts#L55-L61)),
along with `importHelpers: true` in tsconfig, which tells tsc to import
helpers like `__awaiter` from tslib instead of inlining them. tsc never
emitted our build (that was Babel, then Vite), but with `importHelpers`
on, typechecking fails with TS2354 if tslib can't be resolved and the
target needs a helper, as ours did while it was es2015. #2078 raised the
target to es2020 and #3075 removed `importHelpers`. It is still
installed through `@peculiar/x509` and others.
- `@tailwindcss/container-queries` was added in #2654 for the
`@container` and `@[48rem]:` variants on the instance metrics tabs,
loaded as a plugin in `tailwind.config.ts`. Tailwind 4 [has container
queries built
in](https://github.com/tailwindlabs/tailwindcss-container-queries/blob/7a968b3/README.md?plain=1#L1-L2),
and #2910 deleted the config file that loaded the plugin but left the
package.
- `@tanstack/react-query-devtools` was added in #1238 to show the React
Query devtools panel in dev. It was commented out in
cc67cff to keep it out of screenshots,
and #3400 deleted the commented-out lines.
- `react-is` and `@types/react-is` also came from the Nx generator,
which adds them alongside styled-components
([source](https://github.com/nrwl/nx/blob/313552b/packages/react/src/utils/styled.ts#L18-L28))
because styled-components 5 has react-is as a peer dependency. We
replaced styled-components with emotion in
451bef6. `@reach/menu-button` 0.16 also
had react-is as a peer dependency until #1395 replaced it with Radix,
and no package in the lockfile has had one since. Nothing in the repo
has ever imported react-is, so the types were never used.
- `@react-router/node` was added in #3400, following the [React Router
SPA
guide](https://github.com/remix-run/react-router/blob/f482813/docs/how-to/spa.md#L38),
which says a project needs it for the build-time render of `index.html`.
Our `entry.server.tsx` uses web streams and doesn't import it, and
`@react-router/dev` already depends on the exact same version, so it
stays installed.

This branch was successfully deployed

1 active deployment
Preview — 13c9865c Deployed Mar 14, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants