[internal] Use @base-ui/utils/platform for platform detection#22710
Merged
Conversation
romgrk
commented
Jun 9, 2026
LukasTy
reviewed
Jun 9, 2026
LukasTy
left a comment
Member
There was a problem hiding this comment.
LGTM with a few observations.
Claude review
Blocking (external dependency, not a code defect)
| # | Item | Detail |
|---|---|---|
| 1 | Unreleased ./platform subpath |
The cataloged and latest-published @base-ui/utils is 0.2.9, whose exports has no ./platform entry. Every import { platform } from '@base-ui/utils/platform' therefore fails to resolve, which is what turns typecheck/unit/browser/build/package CI red. Unblock by publishing a base-ui version that exposes ./platform, then bump the catalog (pnpm-workspace.yaml:18, currently ^0.2.9). |
| 2 | Lockfile not regenerated | @base-ui/utils was added to 5 package.json files but pnpm-lock.yaml is untouched, so pnpm install --frozen-lockfile fails on its own. Run pnpm install (+ pnpm dedupe) and commit the lockfile once the new version is cataloged. |
Suggestions
| # | File | Suggestion |
|---|---|---|
| 1 | KeyboardManager.ts:107 (and confirm useGridCellSelection.ts:306) |
Real behavior change worth a conscious decision: base-ui os.mac is !ios && platform.startsWith('mac') and excludes iPadOS (it routes platform === 'macintel' && maxTouchPoints > 1 to ios), whereas the old navigator.platform.includes('Mac') treated iPad as Mac. So in the cross-platform ControlOrMeta check, an iPad with a keyboard now maps to Control instead of Meta/Cmd. If iPad should keep Cmd semantics, use platform.os.apple (= mac |
What Looks Good
- Equivalence verified against base-ui source:
engine.gecko= Firefox,os.android/os.macas expected, andenv.jsdom = /jsdom|happydom/so HappyDOM is still matched (no regression vs the old/jsdom|HappyDOM/). @mui/x-internalsuses a"./*": "./src/*/index.ts"wildcard export, so deleting the platform source needs no export-map cleanup.- Dependency hygiene is right: the 4 newly-importing packages declare
@base-ui/utils, x-tree-view-pro already had it, and root gets it as a devDependency for thetest/utils/skipIfhelper. - Good cleanup: dead
isAndroidexport removed and telemetry/formatNumbertests redirected to the sharedskipIfhelper, cutting duplicated detection logic.
base-ui os.mac excludes iPadOS (routed to os.ios), so an iPad with a keyboard would map ControlOrMeta to Control. Use os.apple (mac || ios) to keep Cmd/Meta as the primary modifier on Apple platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The 0.3.0 exports map dropped the ./store/useStore deep subpath, so import it from ./store instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploy previewhttps://deploy-preview-22710--material-ui-x.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
This reverts commit 5571aab.
… into refactor-platform-detection
@base-ui/utils 0.3.0 removed the "./*" wildcard export, so the deep "./store/useStore" subpath no longer resolves. Import from the package's "./store" entry point, which re-exports useStore, instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
LukasTy
approved these changes
Jun 18, 2026
LukasTy
left a comment
Member
There was a problem hiding this comment.
LGTM. 👍
Great work, nice improvement.
Contributor
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…s.ts Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com> Signed-off-by: Rom Grk <romgrk@users.noreply.github.com>
# Conflicts: # packages/x-internals/src/platform/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces MUI X's ad-hoc platform/navigator detection with the new
@base-ui/utils/platformmodule, removing the duplicated in-house detection code.Changes
Removed old detection code:
packages/x-internals/src/platform/index.ts(isFirefox,isJSDOM)packages/x-data-grid/src/utils/isJSDOM.ts(duplicateisJSDOM)isAndroidexport inuseField.utils.tsand the localisAndroidin tree-view-pro'sitemPlugin.tsMigrated to
@base-ui/utils/platformflags:platform.isFirefoxplatform.engine.geckoplatform.isJSDOM/isJSDOMplatform.env.jsdomnavigator.platformMac checksplatform.os.macisAndroid()platform.os.androidTouched:
x-virtualizer,x-data-grid,x-data-grid-premium,x-internal-gestures,x-tree-view-pro.Tests: redirected telemetry +
formatNumbertests to the sharedtest/utils/skipIfhelper; refactoredskipIf.tsitself (isJSDOM→env.jsdom,isOSX→os.mac) and anavigator.platformcheck in the cell-selection test.Dependencies: added
@base-ui/utilsto the consuming packages and to root devDependencies (for the test helper).Notes
useReduceAnimations.tsis intentionally left untouched — it needs OS version numbers, which the boolean platform module doesn't express. Whether to keep/replace that heuristic is a separate behavior decision.platformsubpath only exists in the not-yet-released@base-ui/utils, so wiring it up (linking/rebuilding the local checkout) is still pending — CI typecheck/tests won't pass until then.eslintpasses.🤖 Generated with Claude Code