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.

When clicking on ng-select, can't do stopPropagation to parent element

See original GitHub issue

Hi,

I have the following senario:

<div class="parent" (click)="onClick($event)">
   <ng-select
              [options]="options"
              (selected)="onItemSelected($event)">
   </ng-select>
</div>

I want to prevent onClick from being called each time I open/close ng-select dropdown.

I try to add (click) handler on ‘ng-select’ and call stopPropagation but it will not close the dropdown since it’s listening to window.click.

Can you please advise?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
brucepccommented, May 19, 2020

Hi, I’ve the same issue, to workaround i did it:

<ng-select (click)="$event.stopImmediatePropagation()"></ng-select>

Thanks

1reaction
Quentiguscommented, Mar 4, 2020

Hello, I’ve the same issue with an ng-select within a ngx-bootstrap’s popover [outsideClick]="true" (https://valor-software.com/ngx-bootstrap/#/popover#outside-click)

On option selection, the popover is automaticly closed. Having event returned into selected event will allow us to stop propagation.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

When clicking on ng-select, can't do stopPropagation to parent ...
Hi,. I have the following senario: <div class="parent" (click)="onClick($event)"> <ng-select [options]="options" ...
Read more >
angularjs - What's the best way to cancel event propagation ...
If you insert ng-click="$event.stopPropagation" on the parent element of your template, the stopPropogation will be caught as it bubbles up ...
Read more >
How to Handle Click Events Not Bubbling Up to Document
The most obvious solution is to stopPropagation of the dropdown clicks to prevent the bubble-up. ... This fixes the unwanted expand/collapse of the...
Read more >
AngularJS: Stopping event propagation on ng-click
If you do not want to add this code in all ngClick handlers, you can also use a directive which will install a...
Read more >
can't bind to 'items' since it isn't a known property of 'ng-select'
B) The stub I suggest isn't a module - it is barely even a component. There is no need to incorporate the stub...
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