-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(option): emit selection change when selection is changed #1334
Conversation
Previously NbOptionComponent 'selectionChange' where emitted only when option clicked, ignoring cases where select/deselect methods were called from NbSelectComponent. Also deprecates NbSelectComponent 'selectionChange' property. We already has 'selectedChange' for this. Also 'selectionChange' name is a bit confusing since it emits only when option clicked.
Flush microtask registered in ngAfterViewInit of select component. Then call detect changes in case option were selected.
Also moves test related to select into select describe
Codecov Report
@@ Coverage Diff @@
## master #1334 +/- ##
==========================================
+ Coverage 81.14% 81.17% +0.03%
==========================================
Files 232 232
Lines 7048 7049 +1
Branches 598 598
==========================================
+ Hits 5719 5722 +3
+ Misses 1152 1151 -1
+ Partials 177 176 -1
|
/** | ||
* Stream of events that will fire when one of the options fire selectionChange event. | ||
* */ | ||
/* @deprecated */ | ||
protected selectionChange$: Subject<NbOptionComponent<T>> = new Subject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is internal change there is no need to deprecate it, we can just break it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 5ca3837
@@ -115,10 +122,10 @@ export class NbOptionComponent<T> implements OnDestroy { | |||
* Also Angular can call writeValue on destroyed view (select implements ControlValueAccessor). | |||
* angular/angular#27803 | |||
* */ | |||
if (this.alive) { | |||
if (this.alive && this.selected !== isSelected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since instance variable is called selected
why don't we call local variable same selected
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 0a89ed2
Please read and mark the following check list before creating a pull request:
Short description of what this resolves:
Previously NbOptionComponent 'selectionChange' where emitted only when
option clicked, ignoring cases where select/deselect methods were called
from NbSelectComponent.
Also deprecates NbSelectComponent 'selectionChange' property.
We already has 'selectedChange' for this. Also 'selectionChange' name is
a bit confusing since it emits only when option clicked.