question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mat autocomplete input change event bleeds 'event' object

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/material 9.1.2

Is this a regression?

not sure.

Description

The event (change) will pass down an “event” object to the handler, even if it’s not specified as a parameter.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-x78zg6

see the autocomplete-overview-example.html lines 6-7, and their correspoding hander on autocomplete-verview-example.ts lines 65-72.

🔥 Exception or Error

console.log shows that we have an “event” object, although it is not defined in the function parameter list.

🌍 Your Environment

Angular Version: see stackblitz dependencies.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pkozlowski-opensourcecommented, May 6, 2020

@KissBalazs thnx for the additional clarifications! You are totally right to be confused as to why one can access event! It turns out, though, that it is not Angular specific but you are bumping into https://developer.mozilla.org/en-US/docs/Web/API/Window/event

The long story short that browsers will expose event (for the event being processed) on the window. Since window acts as a global in the browser environment, you can access it in your event handler. You would observe the same effect Angular or not.

Going to close this one as it is not specific to Angular but rather to how browsers work. But hey, totally see how this could be confusing!

1reaction
pkozlowski-opensourcecommented, Mar 12, 2020

After a quick scan it looks like a duplicate of #4059 where we’ve got a conflict between the (change) event on an <input> and the change event raised by a directive. Needs more investigation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular material auto complete change event not called when ...
I was set the value to the auto-complete component on ngOnInint method that time i want to call one method based on the...
Read more >
Autocomplete | Angular Material
MatAutocompleteSelectedEvent. Event object that is emitted when an autocomplete option is selected. Properties. Name, Description.
Read more >
disable and enable a button based on condition react js
And updated the value of activityChanged on onChange event of text input as shown below. const handleInputChange = ( event: FormEvent<HTMLInputElement ...
Read more >
Buttons - Bootstrap
Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
Read more >
Angular Material Autocomplete Select Option Event Example
In this example, you will learn angular material autocomplete change event. This post will give you simple example of angular material ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found