Skip to content

Commit

Permalink
fix(module:cascader): update position when click menu item (#7306)
Browse files Browse the repository at this point in the history
* docs: fix typo

* docs(module:skeleton): fix typo

* docs(module:tooltip): fix typo

* fix(module:cascader): update position when click menu item

* fix(module:cascader): fix typo

* fix(module:cascader): use function reposition

* fix(module:cascader): detectChanges before reposition

* docs(module:cascader):  clean up console
  • Loading branch information
yutao331763646 committed Apr 21, 2022
1 parent bea9cf8 commit 4c669a5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions components/cascader/cascader.component.ts
Expand Up @@ -376,10 +376,9 @@ export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit,
// These operations would not mutate data.
this.checkChildren();
this.setDisplayLabel();
this.cdr.detectChanges();
this.reposition();
this.setDropdownStyles();

this.cdr.markForCheck();
});

srv.$loading.pipe(takeUntil(this.destroy$)).subscribe(loading => {
Expand Down Expand Up @@ -597,6 +596,7 @@ export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit,
if (option && option.disabled) {
return;
}

this.el.focus();
this.inSearchingMode
? this.cascaderService.setSearchOptionSelected(option as NzCascaderSearchOption)
Expand Down Expand Up @@ -721,6 +721,7 @@ export class NzCascaderComponent implements NzCascaderComponentAsSource, OnInit,
if (this.overlay && this.overlay.overlayRef && this.menuVisible) {
Promise.resolve().then(() => {
this.overlay.overlayRef.updatePosition();
this.cdr.markForCheck();
});
}
}
Expand Down
1 change: 0 additions & 1 deletion components/cascader/cascader.service.ts
Expand Up @@ -173,7 +173,6 @@ export class NzCascaderService implements OnDestroy {
if (option.disabled) {
return;
}

this.activatedOptions[columnIndex] = option;
this.trackAncestorActivatedOptions(columnIndex);
this.dropBehindActivatedOptions(columnIndex);
Expand Down
4 changes: 3 additions & 1 deletion components/core/overlay/overlay-position.ts
Expand Up @@ -44,7 +44,9 @@ export const DEFAULT_CASCADER_POSITIONS = [
POSITION_MAP.bottomLeft,
POSITION_MAP.bottomRight,
POSITION_MAP.topLeft,
POSITION_MAP.topRight
POSITION_MAP.topRight,
POSITION_MAP.topCenter,
POSITION_MAP.bottomCenter
];

export const DEFAULT_MENTION_TOP_POSITIONS = [
Expand Down
2 changes: 1 addition & 1 deletion components/tooltip/doc/index.zh-CN.md
Expand Up @@ -27,7 +27,7 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
| `[nzTooltipArrowPointAtCenter]` | 箭头指向锚点的中心 | `boolean` | `false` |
| `[nzTooltipTitle]` | 提示文字 | `string \| TemplateRef<void>` | - |
| `[nzTooltipTitleContext]` | 提示文字模板上下文 | `object` | - |
| `[nzTooltipTrigger]` | 触发行为,可选 `hover/focus/click`,为 `null` 时不响应光标事件 | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
| `[nzTooltipTrigger]` | 触发行为,可选 `hover` \| `focus` \| `click`,为 `null` 时不响应光标事件 | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
| `[nzTooltipPlacement]` | 气泡框位置 | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array<string>` | `'top'` |
| `[nzTooltipColor]` | 背景颜色 | `string` | - |
| `[nzTooltipOrigin]` | 气泡框定位元素 | `ElementRef` | - |
Expand Down

0 comments on commit 4c669a5

Please sign in to comment.