-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
} | ||
|
||
/** Gets promise of the chip input harness. */ | ||
async getInput(): Promise<MatChipInputHarness|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.
What do you think of getTextInput
? I'm thinking that just "input" by itself might be too ambiguous
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.
SGTM
static hostSelector = 'mat-basic-chip, mat-chip'; | ||
|
||
/** Gets a promise for the text content the option. */ | ||
async getTextContent(): Promise<string> { |
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.
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'); |
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.
ariaSelected
?
} | ||
|
||
/** Gets a promise for the disabled state. */ | ||
async isDisabled(): Promise<boolean> { |
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.
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.
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.
Maybe we should move this to the MatChipOptionHarness
? Should we not support disabled
on the base MatChip
?
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.
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'; |
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.
Is the input
part necessary?
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, 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'; |
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.
Just one line?
return await ((await this.host()).getAttribute('disabled')) === 'true';
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.
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(); |
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.
Simplify?
return (await this._options()).filter(o => await o.isSelected());
(async
functions automatically wrap non-promise return values into Promises)
8d666d4
to
786ea2f
Compare
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.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Covers the skeleton work for harnesses for the grid + rows + input, listbox + options, and set + chips.