Skip to content

[utils] Fix UA-CH browser detection#4900

Closed
lyzno1 wants to merge 2 commits into
mui:masterfrom
lyzno1:codex/fix-ua-ch-brand-detection
Closed

[utils] Fix UA-CH browser detection#4900
lyzno1 wants to merge 2 commits into
mui:masterfrom
lyzno1:codex/fix-ua-ch-brand-detection

Conversation

@lyzno1
Copy link
Copy Markdown
Contributor

@lyzno1 lyzno1 commented May 24, 2026

This fixes detectBrowser so navigator.userAgentData.brands is no longer converted into a synthetic user-agent string before browser checks.

UA Client Hints expose structured brand data, so Edge detection now checks the Microsoft Edge brand directly and keeps the legacy navigator.userAgent fallback for browsers without UA-CH support.

References:

Verification:

  • Added focused tests for UA-CH brands and legacy Edge UA fallback
  • TypeScript and lint pass for the touched utils files

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

commit: 89dff1b

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 24, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-42B(-0.01%) 🔺+12B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,143.38 ms -105.63 ms(-8.5%) | Renders: 50 (+0) | Paint: 1,734.59 ms -160.80 ms(-8.5%)

Test Duration Renders
Slider mount (300 instances) 147.87 ms ▼-53.90 ms(-26.7%) 3 (+0)

11 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 24, 2026

Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 89dff1b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a12a5ca511ff600077932be
😎 Deploy Preview https://deploy-preview-4900--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@lyzno1 lyzno1 marked this pull request as ready for review May 24, 2026 07:24
@lyzno1 lyzno1 requested a review from romgrk as a code owner May 24, 2026 07:24
@romgrk
Copy link
Copy Markdown
Contributor

romgrk commented May 24, 2026

What's the motivation for this change? As much as I enjoy getting rid of legacy APIs, if it's working, I wouldn't touch it. The UA string is not going away.

@lyzno1
Copy link
Copy Markdown
Contributor Author

lyzno1 commented May 25, 2026

What's the motivation for this change? As much as I enjoy getting rid of legacy APIs, if it's working, I wouldn't touch it. The UA string is not going away.

That’s fair.

The existing behavior works for current mainstream UA values. The motivation here wasn’t to remove the legacy UA fallback — this still keeps navigator.userAgent for browsers without UA-CH support.

The narrow issue I was trying to address is that userAgentData.brands is structured data, but the current helper turns it into a synthetic UA string and then runs the existing browser regexes against it. That can make UA-CH GREASE/arbitrary brands participate in checks that were originally written for the legacy UA string.

That said, I agree this is more of a correctness hardening than a user-visible bug. If you’d rather avoid touching this while the current behavior works, I’m happy to close the PR.

@lyzno1 lyzno1 closed this May 25, 2026
@lyzno1 lyzno1 deleted the codex/fix-ua-ch-brand-detection branch May 25, 2026 09:47
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