-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material/snackbar): add isDismissed
harness method
#18766
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
// We consider the snackbar dismissed if it's not in the DOM. We can assert that the | ||
// element isn't in the DOM by seeing that its width and height are zero. | ||
const dimensions = await (await this.host()).getDimensions(); | ||
return dimensions.height === 0 && dimensions.width === 0; |
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 how this would behave if it was called mid-animation, right after dismiss
was called. Does the test harness guarantee that all the animations have settled?
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.
Technically the element is already gone, and could not be loaded by the HarnessLoader
again. Though consumers still have a reference to it, so it might be good to expose a method to TestElement
?
The method could then use protractor isPresent
, and in testbed, check if a parent element exists.
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.
@devversion I don't follow what you mean- while the exit animation plays, the snackbar container would still be in the DOM, no?
Seems like the easiest thing to do for the animation would be to add a marker attribute to an existing snackbar and check for that as well.
As for the logic of checking whether the element is in the DOM: checking the geometry gets the job done for now, I would rather just use that until we need to add an isInDom
method for some other use case.
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.
@jelbourn Sorry. I was not chatting about the mid-animation thing @crisbeto mentioned. I was basically saying that figuring out whether an element is in the DOM is a general use-case for such harnesses, and that checking the geometry is a symptom of the problem that consumers can have references to harnesses while the actual host element is already gone.
I agree that checking the geometry does the job for now, but I think long-term adding a method for isPresent
might be useful in TestElement
.
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.
@crisbeto added handling for the animation, PTAL
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 (needs API golden update)
3922efe
to
25110d9
Compare
// Mark this element with a 'dismissing' attribute to indicate that the snackbar has | ||
// been dismissed and will soon be removed from the DOM. This is used by the snackbar | ||
// test harness. | ||
this._elementRef.nativeElement.setAttribute('exit', ''); |
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.
should we call it mat-exit
? also the comment says dismissing
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.
Yeah, I debated this with myself- I figured the prefix wouldn't be strictly necessary since we control the snackbar container and only add it once it's dismissed, but it's fair to say that people might still see it somehow and wonder where it comes from. Added (and fixed the comment).
25110d9
to
9a0b751
Compare
9a0b751
to
adcba68
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. |
No description provided.