-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental/mdc-chips): add remove
method to MDC chip harness
#20831
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
This works towards fixing #20826 |
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.
Could you add a unit test for the remove functionality?
Of course, looking into a unit test now. |
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.
if (!isRemovable) { | ||
throw new Error('This chip is not removable'); | ||
} | ||
|
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 think that we should implement this by dispatching a "delete" keydown
event, instead of going through the remove button since a chip can be removable without having a remove button.
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 trying it that way, but the delete doesn't actually seem to trigger correctly from a 'keydown'
event. Any ideas?
I can debug more easily once this gets synced into our repo.
|
||
/** Indicates if this chip can be deleted. */ | ||
async isRemovable(): Promise<boolean> { | ||
const removeHarness = await this.locatorForOptional(MatChipRemoveHarness)(); |
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.
The presence of a remove button doesn't determine whether a chip is removable, but rather the removable
input. Is there a use case for this method, aside from throwing the error inside remove
? If not, I think that we can get rid of this method since we don't have it on the non-MDC harness either.
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.
Got it, I'll remove this method.
import {ChipRemoveHarnessFilters} from './chip-harness-filters'; | ||
|
||
/** Harness for interacting with a mat-chip removal button in tests. */ | ||
export class MatChipRemoveHarness extends ComponentHarness { |
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.
The non-MDC harness has a click
method so we should probably add it to this one too.
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.
Sorry, that's outside the scope of what I'd like to accomplish here.
Also I'm not sure why the CI checks aren't running against this PR. |
@MatteoVH you wouldn't happen to have CircleCI set up on your fork, would you? |
I don't believe I do, checking my github integrations on CircleCI doesn't show any. |
eb0f2d3
to
a9ffa7a
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.
The recent changes LGTM once the CI is green.
Hey @crisbeto, The |
Without having dived into it, here are a couple of things that you can try:
|
remove
method to MDC chip harness
3f2299a
to
c702990
Compare
…p harness This allows MDC chips to be removed in testing environments. Note that the harness must not only click on the remove button, but also dispatch a `transitionend` event. Without the dispatch of this event, the chip would not fire it's `removed` output. This PR also includes a basic MDC ChipRemoveHarness that mirrors the non-MDC version. This was necessary to find the ChipRemove button in the chip harness' `remove` method.
83a26eb
to
e6cb039
Compare
@crisbeto, looks like I was misspelling the event type. Should be all good now. |
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. |
This allows MDC chips to be removed in testing environments.
Note that the harness must not only click on the remove button, but also dispatch a
transitionend
event. Without the dispatch of this event, the chip would not fire it'sremoved
output.This PR also includes a basic MDC ChipRemoveHarness that mirrors the non-MDC version. This was necessary to find the ChipRemove button in the chip harness'
remove
method.