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(module:time-picker): placeholder not update with i18n changes #6069

Merged
merged 14 commits into from
Dec 15, 2020

Conversation

DepickereSven
Copy link
Contributor

@DepickereSven DepickereSven commented Nov 18, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

When you update the i18n.setLocale() after a few seconds the placeholder of the time-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?

[ ] Yes
[x] No

Other information

@zorro-bot
Copy link

zorro-bot bot commented Nov 18, 2020

This preview will be available after the AzureCI is passed.

@DepickereSven DepickereSven changed the title Dep s/time placeholder i18n fix(module:timepicker): placeholder not update with i18n changes Nov 18, 2020
@codecov
Copy link

codecov bot commented Nov 18, 2020

Codecov Report

Merging #6069 (0d50558) into master (860dfed) will decrease coverage by 0.00%.
The diff coverage is 94.73%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
components/back-top/back-top.component.ts 89.09% <ø> (ø)
components/layout/layout.component.ts 100.00% <ø> (ø)
components/message/message-container.component.ts 91.66% <ø> (ø)
components/page-header/page-header.component.ts 85.00% <ø> (ø)
...ponents/time-picker/time-picker-panel.component.ts 89.02% <ø> (ø)
components/tooltip/base.ts 91.03% <ø> (ø)
components/upload/upload-list.component.ts 95.86% <ø> (ø)
components/result/result.component.ts 92.30% <50.00%> (-0.80%) ⬇️
components/card/card.component.ts 93.33% <100.00%> (ø)
components/checkbox/checkbox-group.component.ts 100.00% <100.00%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 860dfed...0d50558. Read the comment docs.

@DepickereSven
Copy link
Contributor Author

DepickereSven commented Dec 14, 2020

@wenqi73 is it possible to review this PR?
It's an annoying bug that the language isn't correct when you reload the page.

Copy link
Member

@wenqi73 wenqi73 left a 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.

Comment on lines 289 to 292
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe(
map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder),
startWith(this.i18n.getLocaleData(`TimePicker.lang.placeholder`))
);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Depickere Sven added 2 commits December 15, 2020 11:00
@DepickereSven
Copy link
Contributor Author

@wenqi73 I added a test case for the change I made.
But I had also a merge conflict to solve.
I resolved the merge conflict with a merge from master and now I have a lot of file changes.
But they are formatting changes, do I need to create a new PR or is it okay like this?

Comment on lines 212 to 214
ngOnInit(): void {
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe(map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder));
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
i18nPlaceHolder$: Observable<string | undefined> = of(undefined);

@@ -166,20 +188,28 @@ describe('time-picker', () => {
(ngModelChange)="onChange($event)"
[(nzOpen)]="open"
(nzOpenChange)="openChange($event)"
[nzPlaceHolder]="i18nPlaceHolder$ | async"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
[nzPlaceHolder]="i18nPlaceHolder$ | async"

let placeHolderValue: string | undefined;
testComponent.i18nPlaceHolder$.subscribe(v => (placeHolderValue = v));

expect(placeHolderValue).toBe('请选择时间');
Copy link
Member

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;

@wenqi73
Copy link
Member

wenqi73 commented Dec 15, 2020

@DepickereSven The formatting change is OK, no need to change this.

Copy link
Member

@wenqi73 wenqi73 left a comment

Choose a reason for hiding this comment

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

Thanks @DepickereSven !

@wenqi73 wenqi73 changed the title fix(module:timepicker): placeholder not update with i18n changes fix(module:time-picker): placeholder not update with i18n changes Dec 15, 2020
@wenqi73 wenqi73 merged commit f34840b into NG-ZORRO:master Dec 15, 2020
@DepickereSven DepickereSven deleted the depS/time-placeholder-i18n branch December 15, 2020 13:02
@DepickereSven
Copy link
Contributor Author

@wenqi73 You're welcome and thank you for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants