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 #22332: Adjust tests for hidden scrollbar #22337

Merged
merged 1 commit into from
Apr 3, 2017
Merged

Fix #22332: Adjust tests for hidden scrollbar #22337

merged 1 commit into from
Apr 3, 2017

Conversation

deilv
Copy link
Contributor

@deilv deilv commented Apr 2, 2017

On macOS and mobile devices the scrollbar is not part of the document, but rather floats above it. This means that it does not affect body/fixed element padding and scrollbarWidth is equal to 0.

The problem in #22332 was caused by the fact that the test expected padding-right to be increased while opening a modal, but threw an error when it was not (because padding + 0 = padding).

To address the issue the following changes have been made:

  • A copy of the original getScrollbarWidth() function has been added (because the modal function is private)
  • Tests now check if the padding or margin is changed as expected (even if zero) rather than just checking if it changed

@@ -12,6 +12,14 @@ $(function () {
before: function () {
// Enable the scrollbar measurer
$('<style type="text/css"> .modal-scrollbar-measure { position: absolute; top: -9999px; width: 50px; height: 50px; overflow: scroll; } </style>').appendTo('head')
$.fn.getScrollbarWidth = function () {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can add here, why did you add this function

})
.bootstrapModal('show')
// This test only works when the vertical scrollbar is visible and part of the document (which is not the case for macOS and mobile devices)
if ($(this).getScrollbarWidth()) {
Copy link
Member

@Johann-S Johann-S Apr 3, 2017

Choose a reason for hiding this comment

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

It will fail because no test will be run here you should add an else condition

Edit : As I said, see here : https://travis-ci.org/twbs/bootstrap/jobs/217986589

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Conditional removed.

@deilv deilv changed the title Fix #22332: Check if the scrollbar affects the document before running the padding tests Fix #22332: Adjust tests for hidden scrollbar Apr 3, 2017
@wuxue12
Copy link

wuxue12 commented Apr 3, 2017 via email

@deilv
Copy link
Contributor Author

deilv commented Apr 3, 2017

@Johann-S I modified the tests to check if the padding/margin is changed as expected, even if that is zero. Should no longer give errors, but please give it a try. You may want to clear the "changes requested" flag, since I forced a push on the previous commit to keep it clean.

@Johann-S
Copy link
Member

Johann-S commented Apr 3, 2017

Thank you @deilv every tests passed (https://travis-ci.org/twbs/bootstrap/jobs/218028318)

@Johann-S Johann-S added this to the v4.0.0-beta milestone Apr 3, 2017
@Johann-S Johann-S merged commit e6e070b into twbs:v4-dev Apr 3, 2017
@mdo mdo mentioned this pull request Apr 3, 2017
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.

3 participants