Skip to content
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(overlay): fix click trigger #912

Merged
merged 3 commits into from
Oct 16, 2018
Merged

fix(overlay): fix click trigger #912

merged 3 commits into from
Oct 16, 2018

Conversation

nnixaa
Copy link
Collaborator

@nnixaa nnixaa commented Oct 16, 2018

Closes #907

@nnixaa nnixaa requested a review from Tibing October 16, 2018 12:58
// of the container and then later on decide should we hide it or show
// if we track the click & state separately this will case a behavior when the container is getting shown
// and then hidden right away
protected click$: Observable<any[]> = observableFromEvent<Event>(this.document, 'click')
Copy link
Member

Choose a reason for hiding this comment

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

Why do you prefer Observable<any[]> to Observable<[boolean, Event]>?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it just doesn't work as Observable<[boolean, Event]> :)

}
readonly hide$: Observable<Event> = this.click$
.pipe(
filter(([shouldShow]) => !shouldShow),
Copy link
Member

Choose a reason for hiding this comment

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

Let's unite both filters applied to this stream. I don't think we have to separate them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

don't you think it looks cleaner?

Copy link
Member

Choose a reason for hiding this comment

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

I think it calls two filter function instead of one)

@@ -91,8 +97,7 @@ export class NbHoverTriggerStrategy extends NbTriggerStrategy {
.pipe(
debounceTime(100),
takeWhile(() => !!this.container()),
filter(event => !this.host.contains(event.target as Node)
&& !this.container().location.nativeElement.contains(event.target as Node),
filter(event => !this.isOnHostOrContainer(event),
Copy link
Member

Choose a reason for hiding this comment

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

You've personally introduced isNotOnHostOrContainer)

@@ -109,6 +114,8 @@ export class NbHintTriggerStrategy extends NbTriggerStrategy {
.pipe(
delay(100),
takeUntil(observableFromEvent(this.host, 'mouseleave')),
// this `delay & takeUntil & repeat` operators combination is a synonym for `conditional debounce`
// meaning that if one event occurs in some time afther the initial one we won't react to it
Copy link
Member

Choose a reason for hiding this comment

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

...in some time afther the initial one we won't...

import { ComponentRef } from '@angular/core';
import { map } from 'rxjs/operators';
Copy link
Member

Choose a reason for hiding this comment

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

Let's unite two rxjs/operators imports;

@nnixaa nnixaa merged commit 08c2eb6 into master Oct 16, 2018
@nnixaa nnixaa deleted the fix/click-trigger branch October 16, 2018 16:55
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.

None yet

2 participants