8000 fix(mention): fix popover position when data changed · atinc/ngx-tethys@0651d3d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 0651d3d

Browse files
walkerkaywhy520crazy
authored andcommitted
fix(mention): fix popover position when data changed
1 parent 9056844 commit 0651d3d

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/mention/mention.directive.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ export class ThyMentionDirective implements OnInit {
9696

9797
if (this.openedSuggestionsRef) {
9898
this.openedSuggestionsRef.componentInstance.search(matched.query);
99-
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
100-
this.openedSuggestionsRef.updatePosition();
101-
});
10299
}
103100
}
104101

src/mention/suggestions/suggestions.component.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Component, OnInit, OnDestroy, HostBinding, ElementRef } from '@angular/core';
1+
import { Component, OnInit, OnDestroy, HostBinding, ElementRef, NgZone } from '@angular/core';
22
import { Subject, Observable, of } from 'rxjs';
33
import { ThySelectionListChange } from '../../list';
44
import { MentionDefaultDataItem, Mention, MentionSuggestionSelectEvent } from '../interfaces';
5-
import { debounceTime, switchMap, catchError } from 'rxjs/operators';
5+import { debounceTime, switchMap, catchError, take } from 'rxjs/operators';
66
import { SeekQueryResult } from '../adapter/adapter';
7+
import { ThyPopoverRef } from '../../popover';
78

89
@Component({
910
selector: 'thy-mention-suggestions',
@@ -24,7 +25,11 @@ export class ThyMentionSuggestionsComponent<TItem = MentionDefaultDataItem> impl
2425

2526
@HostBinding('class.thy-mention-suggestions') suggestionsClass = true;
2627

27-
constructor(public elementRef: ElementRef<HTMLElement>) {
28+
constructor(
29+
public elementRef: ElementRef<HTMLElement>,
30+
private ngZone: NgZone,
31+
private popoverRef: ThyPopoverRef<any>
32+
) {
2833
this.search$
2934
.pipe(
3035
switchMap(query => {
@@ -44,6 +49,12 @@ export class ThyMentionSuggestionsComponent<TItem = MentionDefaultDataItem> impl
4449
.subscribe(data => {
4550
this.loadingDone = true;
4651
this.data = data;
52+
53+
if (this.popoverRef) {
54+
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
55+
this.popoverRef.updatePosition();
56+
});
57+
}
4758
});
4859
}
4960

src/popover/popover.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class ThyPopover extends ThyUpperOverlayService<ThyPopoverConfig, ThyPopo
6565
);
6666
const positions = getFlexiblePositions(config.placement, config.offset, 'thy-popover');
6767
positionStrategy.withPositions(positions);
68+
positionStrategy.withGrowAfterOpen(true);
6869
positionStrategy.positionChanges.pipe(takeUntil(this.ngUnsubscribe$)).subscribe(change => {
6970
if (change.scrollableViewProperties.isOverlayClipped) {
7071
// After position changes occur and the overlay is clipped by

0 commit comments

Comments
 (0)
0