Skip to content

feat(material-experimental/mdc-chips): add harness skeleton #16737

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

Merged
merged 3 commits into from
Aug 29, 2019

Conversation

andrewseguin
Copy link
Contributor

Covers the skeleton work for harnesses for the grid + rows + input, listbox + options, and set + chips.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 9, 2019
@andrewseguin andrewseguin added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release pr: merge safe labels Aug 9, 2019
}

/** Gets promise of the chip input harness. */
async getInput(): Promise<MatChipInputHarness|null> {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of getTextInput? I'm thinking that just "input" by itself might be too ambiguous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM

static hostSelector = 'mat-basic-chip, mat-chip';

/** Gets a promise for the text content the option. */
async getTextContent(): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

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

Just getText? That's what I used for button and I think we should probably be consistent


/** Gets a promise for the disabled state. */
async isDisabled(): Promise<boolean> {
const ariaSelected = (await this.host()).getAttribute('aria-disabled');
Copy link
Member

Choose a reason for hiding this comment

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

ariaSelected?

}

/** Gets a promise for the disabled state. */
async isDisabled(): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this one. A chip by itself doesn't have any interactive role, and thus being disabled doesn't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should move this to the MatChipOptionHarness? Should we not support disabled on the base MatChip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved it to the option, we can evaluate whether the MdcMatChip should have disabled as an input

* @dynamic
*/
export class MatChipInputHarness extends ComponentHarness {
static hostSelector = 'input.mat-mdc-chip-input';
Copy link
Member

Choose a reason for hiding this comment

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

Is the input part necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, can't remember why I included that but it doesn't seem necessary

/** Gets a promise for the disabled state. */
async isDisabled(): Promise<boolean> {
const ariaSelected = (await this.host()).getAttribute('disabled');
return await ariaSelected === 'true';
Copy link
Member

Choose a reason for hiding this comment

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

Just one line?

return await ((await this.host()).getAttribute('disabled')) === 'true';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not as readable to me but perhaps my brain is still adjusting to awaits


/** Gets promise of the selected options. */
async getSelected(): Promise<MatChipOptionHarness[]> {
const options = await this._options();
Copy link
Member

Choose a reason for hiding this comment

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

Simplify?

return (await this._options()).filter(o => await o.isSelected());

(async functions automatically wrap non-promise return values into Promises)

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

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Aug 29, 2019
@jelbourn jelbourn merged commit 52c33c7 into angular:master Aug 29, 2019
@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 29, 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 P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants