Skip to content

Commit

Permalink
fix: wrong browser link and background shown (#2051)
Browse files Browse the repository at this point in the history
* fix: object.keys returns empty array from navigator window

* chore: tweak changeset
  • Loading branch information
magiziz authored Jun 18, 2024
1 parent 7b00be5 commit d81935c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-cobras-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rainbow-me/rainbowkit": patch
---

Resolved an issue where `Object.keys(navigator).length` returned `0` because it couldn't access object properties due to how `navigator` window API works. This fix should now show the desired browser link and background when trying to install an extension from connect modal.
3 changes: 1 addition & 2 deletions packages/rainbowkit/src/utils/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export enum BrowserType {

export function getBrowser(): BrowserType {
// bail out if `navigator` or `navigator.userAgent` is not available
if (typeof navigator === 'undefined' || Object.keys(navigator).length === 0)
return BrowserType.Browser;
if (typeof navigator === 'undefined') return BrowserType.Browser;
const ua = navigator.userAgent?.toLowerCase();
// @ts-ignore - brave is not in the navigator type
if (navigator.brave?.isBrave) return BrowserType.Brave;
Expand Down

0 comments on commit d81935c

Please sign in to comment.