Skip to content
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

fix(dialog): Cancel open's rAF when close is called #4087

Merged
merged 5 commits into from
Nov 15, 2018

Conversation

kfranqueiro
Copy link
Contributor

@kfranqueiro kfranqueiro commented Nov 15, 2018

This fixes a bug in Dialog when open() and close() are called on the same frame, where the dialog is visually open but internally its state says it's closed, which then makes close() do nothing on subsequent calls.

I discovered this in the wake of Abhinay discovering an issue with the current snackbar JS PR (#4081), after he fixed a similar type of issue for Drawer (#4078). We're probably going to model snackbar off of dialog, so I wanted to make sure that worked.

To repro the original issue using this branch:

  1. Comment out the fix in #close
  2. npm start
  3. Open http://localhost:8080/spec/mdc-dialog/classes/baseline-alert.html
  4. Open the console and run:
    var dialog = mdc.testFixture.dialogs[0];
    dialog.open();
    dialog.close();

(This issue only happens on the same frame, due to neglecting to cancel #open's rAF.)

@codecov-io
Copy link

codecov-io commented Nov 15, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@2ae6335). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4087   +/-   ##
=========================================
  Coverage          ?   98.67%           
=========================================
  Files             ?      126           
  Lines             ?     5603           
  Branches          ?      746           
=========================================
  Hits              ?     5529           
  Misses            ?       74           
  Partials          ?        0
Impacted Files Coverage Δ
packages/mdc-dialog/foundation.js 100% <100%> (ø)

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 2ae6335...10cbc71. Read the comment docs.

@mdc-web-bot
Copy link
Collaborator

All 663 screenshot tests passed for commit ff2aa07 vs. master! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 663 screenshot tests passed for commit bc933e4 vs. master! 💯🎉

Copy link
Contributor

@acdvorak acdvorak left a comment

Choose a reason for hiding this comment

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

LGTM!

Confirmed that this also works in #4081. Thanks Ken!

@mdc-web-bot
Copy link
Collaborator

All 663 screenshot tests passed for commit 205e90b vs. master! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 663 screenshot tests passed for commit 10cbc71 vs. master! 💯🎉

@kfranqueiro kfranqueiro merged commit 2516c25 into master Nov 15, 2018
@kfranqueiro kfranqueiro deleted the fix/dialog/open-close branch November 15, 2018 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants