-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(module:slider): support nzTooltipVisible #2817
Conversation
Deploy preview for ng-zorro-master ready! Built with commit 8155fcd |
Deploy preview for ng-zorro-master ready! Built with commit 81aab73 |
Codecov Report
@@ Coverage Diff @@
## master #2817 +/- ##
==========================================
+ Coverage 97.36% 97.37% +<.01%
==========================================
Files 524 527 +3
Lines 11042 10995 -47
Branches 782 793 +11
==========================================
- Hits 10751 10706 -45
+ Misses 190 185 -5
- Partials 101 104 +3
Continue to review full report at Codecov.
|
components/core/util/number.ts
Outdated
if (isNaN(num) || num < min) { | ||
return min; | ||
} else if (num > max) { | ||
console.log('captured max'); |
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.
no console
it('should pass un-covered code testing', () => { | ||
expect(sliderInstance.getValueToOffset()).toBe(sliderInstance.value); | ||
it('should always display tooltip work', () => { | ||
|
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.
miss test
}); | ||
|
||
it('should never display tooltip word', () => { | ||
|
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.
miss test
components/slider/doc/index.en-US.md
Outdated
@@ -28,5 +28,6 @@ To input a value in a range. | |||
| `[nzTipFormatter]` | Slider will pass its value to `tipFormatter`, and display its value in Tooltip, and hide Tooltip when return value is null. | `(value: number) => string` | - | | |||
| `[ngModel]` | The value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | `number|number[]` | - | | |||
| `[nzVertical]` | If true, the slider will be vertical. | `boolean` | `false` | | |||
| `[nzTooltipVisible]` | When set to `always` tooltips are always displayed. When set to `never` they are never displayed | `default|always|never` | `default` | |
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.
should be 'default'|'always'|'never'
components/slider/doc/index.zh-CN.md
Outdated
@@ -29,5 +29,6 @@ title: Slider | |||
| `[nzTipFormatter]` | Slider 会把当前值传给 `nzTipFormatter`,并在 Tooltip 中显示 `nzTipFormatter` 的返回值,若为 null,则隐藏 Tooltip。 | `(value: number) => string` | - | | |||
| `[ngModel]` | 设置当前取值。当 `range` 为 `false` 时,使用 `number`,否则用 `[number, number]` | `number|number[]` | - | | |||
| `[nzVertical]` | 值为 `true` 时,Slider 为垂直方向 | `boolean` | `false` | | |||
| `[nzTooltipVisible]` | 值为 `always` 时总是显示,值为 `never` 时在任何情况下都不显示 | `default|always|never` | `default` | |
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.
'default'|'always'|'never'
selector : 'nz-slider-handle', | ||
preserveWhitespaces: false, | ||
templateUrl : './nz-slider-handle.component.html' | ||
}) | ||
export class NzSliderHandleComponent implements OnChanges { | ||
export class NzSliderHandleComponent implements OnChanges, AfterViewInit, OnDestroy { | ||
@ViewChild('tooltip') tooltip: NzToolTipComponent; |
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.
@ViewChild(NzToolTipComponent)
} | ||
} | ||
if (nzTooltipVisible && !nzTooltipVisible.isFirstChange()) { | ||
this.tooltip.show(); |
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.
tooltip may be null
} | ||
|
||
// NOTE: run outside of Angular for performance consideration. | ||
this.ngZone.runOutsideAngular(() => { |
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.
actually, there is no need to add runOutsideAngular here, use host:{ 'mouseenter' } is ok
} | ||
|
||
if (show) { | ||
this.tooltip.show(); |
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.
this.tooltip maybe null
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.
private toggleTooltip(show: boolean): void {
if (this.nzTooltipVisible !== 'default' || !this.tooltip) {
return;
}
if (show) {
this.tooltip.show();
} else {
this.tooltip.hide();
}
}
If this.tooltip
is null the method returns ahead of this.
@vthinkxie Fixed. Please review again. |
close NG-ZORRO#2373 test: add test fix: fix hover handles rebase
close #2373
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #2373
What is the new behavior?
Does this PR introduce a breaking change?
Other information