Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Fix modal dismissal #702

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fix modal dismissal #702

wants to merge 4 commits into from

Conversation

rabidbit
Copy link
Contributor

The dismiss button on the modal does not dismiss the modal in a smooth manner. Hitting the "Get Feedback" button also dismisses the modal abruptly (it just disappears).

@codecov
Copy link

codecov bot commented Dec 14, 2018

Codecov Report

Merging #702 into master will decrease coverage by 0.19%.
The diff coverage is 13.63%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #702     +/-   ##
=========================================
- Coverage   95.86%   95.67%   -0.2%     
=========================================
  Files         129      129             
  Lines        6336     6352     +16     
  Branches      410      411      +1     
=========================================
+ Hits         6074     6077      +3     
- Misses        262      275     +13
Impacted Files Coverage Δ
...stion/components/MonospaceDisplayModalDirective.js 21.42% <12.5%> (+1.42%) ⬆️
client/question/components/LearnerViewDirective.js 69.43% <14.28%> (-2.79%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8412e36...e2b8800. Read the comment docs.

@rabidbit
Copy link
Contributor Author

rabidbit commented Jan 8, 2019

I added @seanlip for the overall review and @davyrisso-at-google for the E2E test review.

I used browser.sleep() because I could not get browser.wait() to work properly. It works as is, but I suspect using browser.wait() might be more robust? Love to get suggestions on how to make the tests better.

@davyrisso-at-google
Copy link
Contributor

I used browser.sleep() because I could not get browser.wait() to work properly. It works as is, but I suspect using browser.wait() might be more robust? Love to get suggestions on how to make the tests better.

I recommend using await browser.wait() with ExpectedConditions.presenceOf()/visibilityOf()/invisibilityOf().
(See https://www.protractortest.org/#/api?view=ProtractorExpectedConditions for more details)

E.g in pageObjects openModal() would become:

this.openModal = async function() {
// We wait for the modal link to be present.
await browser.wait(
ExpectedConditions.presenceOf(modalLink),
MODAL_LINK_PRESENCE_TIMEOUT);
await modalLink.click();
// We wait for the modal to be visible.
await browser.wait(
ExpectedConditions.invisibilityOf(this.monospaceModalContainerElement),
MODAL_DISMISSAL_TIMEOUT);
};

and dismissModal():

this.dismissModal = async function() {
// We wait for the modal dismissal link to be visible.
await browser.wait(
ExpectedConditions.visibilityOf(dismissModalButton),
MODAL_PRESENCE_TIMEOUT);
await dismissModalButton.click();
// We wait for the modal to be invisible.
await browser.wait(
ExpectedConditions.invisibilityOf(this.monospaceModalContainerElement),
MODAL_DISMISSAL_TIMEOUT);
};

Note that in the spec it is necessary to use await when calling both these methods, i.e:
await questionPage.openModal();
// Test...
await questionPage.dismissModal();

I am not sure if the current tests in specs are all necessary (e.g testing the presence/absence of the ng-hide class should be taken care of with ExpectedCondition.visibilityOf/invisibilityOf, maybe we should rather test the presence and content of the text in the modal?

Let me know if this works!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @rabidbit, took a first pass.

FWIW, from a UI/UX perspective, I think I personally prefer the current behaviour (no animation on-close), mainly because it's faster. But that's not meant as an override -- it's just a data point for consideration. Feel free to overrule.

/**
* Event handler to hide modal after transition animation ends.
*/
$scope.hideModalAfterAnimation = function(event) {
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 this needs to be defined here; it duplicates code in MonospaceDisplayModalService.

};

/**
* Close modal by calling MonospaceDisplayModalService.closeModal.
Copy link
Member

Choose a reason for hiding this comment

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

The function doesn't seem to be doing what this docstring says.

/**
* Close modal by calling MonospaceDisplayModalService.closeModal.
*/
$scope.closeModal = function() {
Copy link
Member

Choose a reason for hiding this comment

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

The code here duplicates code in MonospaceDisplayModalDirective. In general try to strictly avoid duplicating code since that makes things harder to maintain and introduces the possibility of skew.

* Close the modal.
* Event handler to hide modal after transition animation ends.
*/
$scope.hideModalAfterAnimation = function(event) {
Copy link
Member

Choose a reason for hiding this comment

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

Consider using evt instead of event throughout (which I think we do already).

(event is a global variable in some versions of IE, so typically I avoid using it.)

$timeout(function() {
MonospaceDisplayModalService.hideModal();
}, 0);
event.target.removeEventListener("transitionend",
Copy link
Member

Choose a reason for hiding this comment

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

nit: break after '(' if contents of (...) span more than one line

Here and elsewhere, use single quotes

@rabidbit
Copy link
Contributor Author

rabidbit commented Jan 9, 2019

@seanlip Re: UI/UX, I think it looks janky when it slides down on display and disappears on dismiss. Also, we have #540, which this fixes. I can adjust the dismissal animation to make it faster.

@seanlip
Copy link
Member

seanlip commented Jan 9, 2019

OK. I'm happy to defer on UX.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants