Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Dialog scroll-lock bugfix #2120

Merged

Conversation

tompng
Copy link
Contributor

@tompng tompng commented Jan 29, 2018

When calling dialog.destroy() soon after dialog.close(), the whole window gets scroll-locked.
(when destroy() is called before the close transition ends)

this.enableScroll_() cannnot placed inside if(this.isOpen_){}
because this.close() (it turns this.isOpen_ = false;) does not enableScroll_()

destroy() {
  if (this.isOpen_) {
    ...
    // this.enableScroll_(); // can't be here. scroll-lock state is not syncrhonized with the flag `isOpen_`.
  }
  this.enableScroll_();
}

other possibilities

destroy() {
  if (this.isOpen_) {
    ...
    this.enableScroll_(); // can be here. scroll-lock state is syncrhonized with the flag `isOpen_`.
  }
}
close() {
  this.isOpen_ = false;
  ...
  this.enableScroll_(); // add this
}

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot. The email used to register you as an authorized contributor must be the email used for the Git commit.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@codecov-io
Copy link

codecov-io commented Jan 29, 2018

Codecov Report

Merging #2120 into master will increase coverage by 0.94%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2120      +/-   ##
==========================================
+ Coverage   98.48%   99.43%   +0.94%     
==========================================
  Files          98       84      -14     
  Lines        4230     3720     -510     
  Branches      537      486      -51     
==========================================
- Hits         4166     3699     -467     
+ Misses         64       21      -43
Impacted Files Coverage Δ
packages/mdc-dialog/foundation.js 100% <100%> (ø) ⬆️
packages/mdc-textfield/foundation.js 98.19% <0%> (-0.71%) ⬇️
packages/mdc-checkbox/foundation.js 97.39% <0%> (-0.25%) ⬇️
packages/mdc-icon-toggle/index.js 100% <0%> (ø) ⬆️
packages/mdc-select/foundation.js 100% <0%> (ø) ⬆️
packages/mdc-ripple/foundation.js 100% <0%> (ø) ⬆️
packages/mdc-toolbar/constants.js 100% <0%> (ø) ⬆️
packages/mdc-textfield/icon/foundation.js 100% <0%> (ø) ⬆️
packages/mdc-select/index.js 100% <0%> (ø) ⬆️
packages/mdc-checkbox/constants.js 100% <0%> (ø) ⬆️
... and 51 more

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 e5ad26a...180f3d2. Read the comment docs.

@tompng
Copy link
Contributor Author

tompng commented Jan 29, 2018

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@williamernest williamernest self-assigned this Mar 26, 2018
@williamernest
Copy link
Contributor

@tompng Thanks for submitting this PR. Is there a reason that this.enableScroll_() isn't just moved from the handleTransitionEnd function to line 97, just after 'this.isOpen_ = false;'. It seems like a better place to enable scrolling behavior than to always call it in the destroy function.

@tompng tompng force-pushed the dialog_scrolllock_fix branch from 89a70c1 to 7150bd3 Compare May 15, 2018 06:23
@tompng
Copy link
Contributor Author

tompng commented May 15, 2018

@williamernest

to line 97, just after 'this.isOpen_ = false;'.

I agree, fixed.

Little changes is that, scrolling is enabled before closing animation starts(originally, it was enabled after animation ends), but I think it's not a problem.

Copy link
Contributor

@williamernest williamernest left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for updating this.

@williamernest williamernest merged commit c961a5d into material-components:master May 15, 2018
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.

4 participants