Skip to content

ui: Handle null navigator.keyboard - #7186

Merged
LalitMaganti merged 1 commit into
google:mainfrom
iw4p:codex/fix-null-keyboard-layout-map
Aug 24, 2026
Merged

LalitMaganti merged 1 commit into
google:mainfrom
iw4p:codex/fix-null-keyboard-layout-map

Conversation

@iw4p

@iw4p iw4p commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Problem

Screenshot 2026-08-23 at 23 05 46

In some browsers, the keyboard property exists on navigator but its value is null.

The existing property-presence check succeeds and then calls getLayoutMap() on null, crashing the Perfetto home page:

TypeError: Cannot read properties of null (reading 'getLayoutMap')

Observed with Perfetto UI v58.2 on Chrome 150 on macOS.

Fix

Declare navigator.keyboard as nullable and check its value before calling getLayoutMap().

Unsupported environments now throw the existing NotSupportedError, allowing the UI to use its fallback keyboard layout.

I solved it with declare global because I saw they've been used in other parts, could be fixed with cast but ugly, or runtime guard which's verbose..

Additionally getLayoutMap() genuinely returns a Promise according to the Keyboard Map specification, this is the reason I changed it.

@iw4p
iw4p requested a review from a team as a code owner August 23, 2026 21:11
@google-cla

google-cla Bot commented Aug 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@stevegolton stevegolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the patch!

@LalitMaganti
LalitMaganti enabled auto-merge (squash) August 24, 2026 10:03
@LalitMaganti
LalitMaganti merged commit 52635b8 into google:main Aug 24, 2026
18 of 19 checks passed
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.

4 participants