Skip to content

Fix 'e.getModifierState is not a function' error for browser auto filled form events - #206883

Merged
Alexandru Dima (alexdima) merged 4 commits into
microsoft:mainfrom
BusinessDuck:patch-1
Mar 14, 2024
Merged

Alexandru Dima (alexdima) merged 4 commits into
microsoft:mainfrom
BusinessDuck:patch-1

Conversation

@BusinessDuck

Copy link
Copy Markdown
Contributor

Some browser events may not contains getMidifierState method. For example events, that produced by forms auto-fills.
Check the demo stand in associated issue #205214

Optional chaining for that method should solve the problem.

Test cases:

  1. Autofill form by browser
  2. Create event through the new Event() programmatically and dispatch, that will produce error also because correct way to use new KeyboardEvent()

@silverwind

silverwind commented Mar 9, 2024 •

Copy link
Copy Markdown

Any chance of a swift merge? The diff is trivial and this issue really affects Monaco users heavily.

Dmitriy (@BusinessDuck) can you change the PR title to something descriptive? It might be one reason why the PR was ignored so far.

@BusinessDuck Dmitriy (BusinessDuck) changed the title Update keyboardEvent.ts Fix 'e.getModifierState is not a function' error for browser auto filled form events Mar 9, 2024
@BusinessDuck

Copy link
Copy Markdown
Contributor Author

Is that looks better now?

@silverwind

silverwind commented Mar 9, 2024 •

Copy link
Copy Markdown

Yes, thanks. The fix is good enough to get the error away.

The error also highlights a deeper underlying problem: VSCode should not be "listening in" on events that are targeting elements which are outside of its root element. Essentially, it's being a "bad neighbor" currently.

@alexdima

Copy link
Copy Markdown
Member

Thank you!

@alexdima
Alexandru Dima (alexdima) merged commit b9ca5a6 into microsoft:main Mar 14, 2024
@BusinessDuck
Dmitriy (BusinessDuck) deleted the patch-1 branch March 14, 2024 08:55
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants