-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(module:time-picker): placeholder not update with i18n changes #6069
fix(module:time-picker): placeholder not update with i18n changes #6069
Conversation
This preview will be available after the AzureCI is passed. |
Codecov Report
@@ Coverage Diff @@
## master #6069 +/- ##
==========================================
- Coverage 89.82% 89.81% -0.01%
==========================================
Files 469 477 +8
Lines 14948 15206 +258
Branches 2273 2302 +29
==========================================
+ Hits 13427 13658 +231
- Misses 935 952 +17
- Partials 586 596 +10
Continue to review full report at Codecov.
|
@wenqi73 is it possible to review this PR? |
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.
Thanks for your contribution, add a unit test example would be better.
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe( | ||
map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder), | ||
startWith(this.i18n.getLocaleData(`TimePicker.lang.placeholder`)) | ||
); |
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.i18nPlaceHolder$ = this.i18n.localeChange.pipe( | |
map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder), | |
startWith(this.i18n.getLocaleData(`TimePicker.lang.placeholder`)) | |
); | |
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe( | |
map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder) | |
); |
Already has the initial value, no need to use startWith
.
# Conflicts: # components/time-picker/time-picker.component.ts
@wenqi73 I added a test case for the change I made. |
ngOnInit(): void { | ||
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe(map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder)); | ||
} |
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.
ngOnInit(): void { | |
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe(map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder)); | |
} |
open = false; | ||
openChange = jasmine.createSpy('open change'); | ||
autoFocus = false; | ||
date: Date | string = new Date(); | ||
disabled = false; | ||
use12Hours = false; | ||
nzSuffixIcon?: string; | ||
i18nPlaceHolder$: Observable<string | undefined> = of(undefined); |
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.
i18nPlaceHolder$: Observable<string | undefined> = of(undefined); |
@@ -166,20 +188,28 @@ describe('time-picker', () => { | |||
(ngModelChange)="onChange($event)" | |||
[(nzOpen)]="open" | |||
(nzOpenChange)="openChange($event)" | |||
[nzPlaceHolder]="i18nPlaceHolder$ | async" |
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.
[nzPlaceHolder]="i18nPlaceHolder$ | async" |
let placeHolderValue: string | undefined; | ||
testComponent.i18nPlaceHolder$.subscribe(v => (placeHolderValue = v)); | ||
|
||
expect(placeHolderValue).toBe('请选择时间'); |
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.
placeholder = timeElement.nativeElement.querySelector('input').placeholder;
@DepickereSven The formatting change is OK, no need to change this. |
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.
Thanks @DepickereSven !
@wenqi73 You're welcome and thank you for reviewing! |
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?
When you update the
i18n.setLocale()
after a few seconds the placeholder of thetime-picker component
will not update.Reproduce https://stackblitz.com/edit/angular-qyneqn?file=src/app/app.component.ts
What is the new behavior?
Whenever you update
i18n.setLocale()
the placeholder will also update.Does this PR introduce a breaking change?
Other information