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

feat(select): integrate with Angular forms #1655

Merged
merged 1 commit into from
Nov 3, 2016

Conversation

kara
Copy link
Contributor

@kara kara commented Oct 31, 2016

This PR adds basic forms integration.
Still TODO for forms:

r: @jelbourn

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 31, 2016
@kara kara force-pushed the select-forms branch 7 times, most recently from 053408a to d6d5ca9 Compare October 31, 2016 23:35
@kara kara force-pushed the select-forms branch 2 times, most recently from 9c72f58 to 1c52a54 Compare November 1, 2016 21:06
@@ -46,9 +50,9 @@ export class MdOption {
}

/** Selects the option. */
select(): void {
select(isUserInput = false): void {
Copy link
Member

Choose a reason for hiding this comment

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

This is kind of weird, since it's a public method. How about adding a separate _selectViaInteration method that calls select() and does the emit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes way more sense. Good call.

@@ -25,6 +25,10 @@ md-select {
[dir='rtl'] & {
transform-origin: right top;
}

[aria-required=true] &::after {
content: '*';
Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO here to double-check the accessibility of this.


it('should set the view value from the form', () => {
let value = fixture.debugElement.query(By.css('.md-select-value'));
expect(value).toBeNull();
Copy link
Member

Choose a reason for hiding this comment

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

FYI, don't forget that you can add assertion descriptions to the matchers so that the failures are more clear.
(optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, I always forget about that

writeValue(value: any): void {
if (!this.options) { return; }

this.options.forEach((option: MdOption) => {
Copy link
Member

Choose a reason for hiding this comment

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

If you do this with a for of, you could break out as soon as you find the corresponding option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this.options is a QueryList, so you'd have to use toArray() first.

@kara kara force-pushed the select-forms branch 2 times, most recently from 95bdea5 to 94c1a38 Compare November 2, 2016 20:09
@kara
Copy link
Contributor Author

kara commented Nov 2, 2016

@jelbourn Comments addressed

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM w/ one minor comment on the tests

fixture.detectChanges();

value = fixture.debugElement.query(By.css('.md-select-value'));
expect(value.nativeElement.textContent).toContain('Pizza',
Copy link
Member

Choose a reason for hiding this comment

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

Prefer breaking at the higher syntactic level, e.g.:

expect(value.nativeElement.textContent)
    .toContain('Pizza', `Expected trigger to be populated by the control's new value.`);

(general rule-of-thumb that makes code more readable in all languages)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that does look better. I'll reformat.

@kara kara added the action: merge The PR is ready for merge by the caretaker label Nov 3, 2016
@jelbourn jelbourn merged commit a4ab10f into angular:master Nov 3, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants